Python SDK
Time grains
Aggregate Python dataset queries by minute, hour, day, week, month, quarter, and year.
When a dataset has a time_key, pass a grain as by to bucket results by time period:
analytics.execute(
orders,
DatasetQuery(by="month", dimensions=("country",), measures=("revenue",)),
)Results include a period column, ordered ascending. Buckets are computed in the
query's time zone: DatasetQuery(timezone="America/New_York"), or the client's
default from create_dataset_client(timezone=...), which is UTC unless set.
Supported grains:
minutehourdayweek(weeks start on Sunday)monthquarteryear