Pandas · Build daily and weekly reports
Google Search Analytics
Course overviewGoogle Search · Analyze activity over time

Build daily and weekly reports

Resample UTC events into complete daily and Monday-start weekly calendars.

Step 1 of 3 · Learn

Count events on a date index

.set_index("searched_at").resample("D").size() counts rows in each UTC day. Size counts searches even when other columns are missing. Resampling groups by time; the source rows need not already be chronological.

indextext
02026-07-06T01:00:00Z
12026-07-06T13:00:00Z
22026-07-08T09:00:00Z
indexdatesearches
02026-07-06 00:00:00+00:002
12026-07-07 00:00:00+00:000
22026-07-08 00:00:00+00:001
The explicit calendar keeps the date with no events.

Declare the complete calendar

pd.date_range(start, end, freq="D", tz="UTC") includes both date endpoints. Reindex the counts to that calendar with fill_value=0, so leading, interior, and trailing no-activity dates remain. .rename_axis("date").reset_index(name="searches") turns the date index into a column.

Make Monday-start weeks explicit

Use .resample("W-MON", label="left", closed="left") for buckets from Monday 00:00 UTC up to, but not including, the next Monday. W-MON defaults differ, so specify both options. Filter to the requested reporting interval first, then reindex to its Monday labels.

indextext
02026-07-06T00:00:00Z
12026-07-12T23:59:59Z
22026-07-13T00:00:00Z
indexweek_startsearches
02026-07-06 00:00:00+00:002
12026-07-13 00:00:00+00:001
Sunday ends the first week; the next Monday starts a new bucket.
▷ Your turn

Count all searches per UTC day from July 6 through July 12, 2026, inclusive. Return date and searches, one row per day sorted ascending, with date as a UTC midnight timestamp and 0 for days without searches. Exclude events outside that interval and missing timestamps. Save the DataFrame as result.

LANGUAGEPython · Pandas

Loading Python and Pandas…

Run the code to see DataFrame results here.