Pandas · Find frequently searched queries
Google Search Analytics
Course overviewGoogle Search · Build a search performance report

Find frequently searched queries

Normalize query variants, apply a volume minimum, and rank with deterministic ties.

Step 1 of 3 · Learn

Combine formatting variants, not search events

Trim query edges, lowercase text, and collapse whitespace before grouping. Each search still counts as an event. Exclude missing queries and strings that become empty after cleaning; do not deduplicate the search rows.

indexquery
0 Tea Shops
1tea shops
2COFFEE
indexnormalized_querysearches
0coffee1
1tea shops2
Two formatting variants contribute two searches to the same normalized query.

Apply a minimum before selecting the top rows

Aggregate first, keep query groups with at least the required count, then sort count descending and normalized query ascending. The second key makes tied counts deterministic. Take at most the requested number after filtering.

indexquerysearches
0alpha3
1beta1
2gamma3
indexquerysearches
0alpha3
2gamma3
The count minimum is inclusive; alphabetical order breaks the tie.

Keep the rate at query level

For each normalized query, zero_result_rate is zero-result searches divided by all searches for that query. A Boolean mean computes this proportion. Do not filter to zero-result events before calculating the denominator.

▷ Your turn

Normalize searches.query by trimming, lowercasing, and collapsing whitespace to one space. Exclude missing and empty normalized queries. Return normalized_query and searches for every remaining query group, counting all search events and sorting normalized_query ascending. Save the DataFrame as result.

LANGUAGEPython · Pandas

Loading Python and Pandas…

Run the code to see DataFrame results here.