Pandas · Build the device summary
Google Search Analytics
Course overviewGoogle Search · Build a search performance report

Build the device summary

Combine counts, distinct users, and correctly defined rates in one device report.

Step 1 of 3 · Learn

Choose the unit for each metric

One row in searches is one search. Count all rows for searches and distinct non-missing user_id values for known_users. A person may use several devices, so adding device-level unique users does not give a global unique-user total.

indexdeviceuser
0A7
1A7
2ANA
3B9
indexdevicesearchesknown_users
0A31
1B11
Device A has three searches, but only one distinct known user.

Attach one click marker per search

Deduplicate click search IDs before a one-to-one left merge into searches. Fill only absent clicked markers with 0. Then aggregate at device level, retaining devices without clicks and missing-device groups.

Use the same denominator

search_ctr is clicked searches divided by all searches. zero_result_rate is searches with result_count equal to 0 divided by all searches. Repeated clicks do not add to the first numerator. Keep both rates as unrounded proportions, not percentages.

indexdeviceclickedzero
0A10
1A01
2B00
indexdevicesearchesclicked_searchessearch_ctrzero_result_rate
0A210.50.5
1B1000
Both rates use all searches within the same device group.
▷ Your turn

Return device, searches, known_users, and zero_result_rate for each device. Count all search rows and distinct non-missing user IDs; zero_result_rate is the proportion of searches with result_count equal to 0. Include missing device groups and sort device ascending, missing last. Do not round. Save the DataFrame as result.

LANGUAGEPython · Pandas

Loading Python and Pandas…

Run the code to see DataFrame results here.