Parse text as UTC timestamps and filter complete days with half-open boundaries.
Step 1 of 3 · Learn
Parse text with a timezone
pd.to_datetime(..., utc=True) converts offset-aware text to UTC. Set the known format explicitly and use errors="coerce" to turn invalid text into NaT, the missing timestamp value. UTC-naive input would be interpreted as UTC, not automatically as local time.
index
text
0
2026-07-06T08:00:00-0400
1
invalid
2
NA
↓
index
text
timestamp
0
2026-07-06T08:00:00-0400
2026-07-06 12:00:00+00:00
1
invalid
NA
2
NA
NA
The offset is converted to UTC; invalid and missing inputs become NaT.
Use datetime fields without turning them into text
The .dt accessor works on datetime Series. .dt.hour returns hour numbers; .dt.normalize() sets the time to midnight while retaining timezone information. Avoid formatting timestamps into strings when the next step requires time arithmetic.
Filter one full UTC day
Build timezone-aware boundaries with pd.Timestamp("YYYY-MM-DD", tz="UTC"). Compare >= start and < next_day: this includes every time in the day without accidentally including the next midnight. Missing timestamps do not match.
index
text
0
2026-07-05T23:59:59Z
1
2026-07-06T00:00:00Z
2
2026-07-06T23:59:59Z
3
2026-07-07T00:00:00Z
↓
index
text
1
2026-07-06T00:00:00Z
2
2026-07-06T23:59:59Z
Include the start midnight; exclude the following midnight.
▷ Your turn
From raw_search_times, return search_id and searched_at. Parse searched_at_text using its supplied format into UTC timestamps, coercing invalid and missing text to NaT. Keep all six rows in source order and save the DataFrame as result.
raw_search_times is a six-row copy containing search_id and searched_at_text. The second text is invalid and the third is missing. Valid strings use YYYY-MM-DDTHH:MM:SS followed by a timezone offset. The original searches.searched_at is already a UTC timestamp column and remains unchanged.