aggregate_idata_time#

pymc_marketing.data.idata.utils.aggregate_idata_time(idata, period, method='sum')[source]#

Aggregate DataTree over time periods.

Parameters:
idataxr.DataTree

DataTree to aggregate

period{“original”, “weekly”, “monthly”, “quarterly”, “yearly”, “all_time”}

Time period to aggregate to. Use “original” for no aggregation (returns unchanged), “all_time” to aggregate over the entire time dimension (removes the date dimension).

method{“sum”, “mean”}, default “sum”

Aggregation method

Returns:
xr.DataTree

New DataTree with aggregated groups (or unchanged if period=”original”)

Examples

>>> original = aggregate_idata_time(idata, "original")  # No aggregation
>>> monthly = aggregate_idata_time(idata, "monthly", method="sum")
>>> total = aggregate_idata_time(idata, "all_time", method="sum")