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.
index
text
0
2026-07-06T01:00:00Z
1
2026-07-06T13:00:00Z
2
2026-07-08T09:00:00Z
↓
index
date
searches
0
2026-07-06 00:00:00+00:00
2
1
2026-07-07 00:00:00+00:00
0
2
2026-07-08 00:00:00+00:00
1
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.
index
text
0
2026-07-06T00:00:00Z
1
2026-07-12T23:59:59Z
2
2026-07-13T00:00:00Z
↓
index
week_start
searches
0
2026-07-06 00:00:00+00:00
2
1
2026-07-13 00:00:00+00:00
1
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.