Complete worked example
python
import re
import pandas as pd
def inspect_example(values, zone="UTC"):
if zone not in {"UTC", "Asia/Jerusalem", "Europe/Kyiv"}:
raise ValueError("unsupported teaching zone")
if any(type(v) is not str or not re.search(r"(Z|[+-]\d{2}:\d{2})$", v) for v in values):
raise ValueError("an explicit timestamp offset is required")
stamps = pd.Series(pd.to_datetime(values, format="ISO8601", utc=True, errors="raise"))
day = stamps.dt.tz_convert(zone).dt.strftime("%Y-%m-%d").astype("string")
result = day.to_frame("day").groupby("day").size().rename("events").reset_index()
return result.astype({"day": "string", "events": "Int64"}).sort_values("day").reset_index(drop=True)- Reasoning
- Validate timestamp strings for an offset suffix, parse with format="ISO8601" and utc=True, then convert the resulting timezone-aware Series with tz_convert. Extract the YYYY-MM-DD display key only after conversion. Group those keys to count events, cast the output schema and sort days. Empty input yields the same typed day and events columns. Trace an event at 23:30 UTC and another written as 01:30 with a +02:00 offset. They represent the same instant. They share a UTC date, and also share the following date when reported in Asia/Jerusalem at this fixture date. Different timestamp spelling does not imply different chronology.