MMMSummaryFactory.change_over_time#
- MMMSummaryFactory.change_over_time(hdi_probs=None, frequency=None, output_format=None)[source]#
Create change over time summary with per-date percentage changes.
Computes percentage change in contributions between consecutive time periods: (value[t] - value[t-1]) / value[t-1] * 100 for each date.
- Parameters:
- hdi_probssequence of
float, optional HDI probability levels (default: uses factory default)
- frequency{“original”, “weekly”, “monthly”, “quarterly”, “yearly”}, optional
Aggregate to time frequency before computing changes. Use “original” or None for no aggregation. Cannot use “all_time” (change over time requires date dimension).
- output_format{“pandas”, “polars”}, optional
Output DataFrame format (default: uses factory default)
- hdi_probssequence of
- Returns:
pd.DataFrameorpl.DataFrameSummary DataFrame with columns:
date: Date (excluding first date which has no previous)
channel: Channel name
pct_change_mean: Mean percentage change
pct_change_median: Median percentage change
abs_error_{prob}_lower: HDI lower bound for each prob
abs_error_{prob}_upper: HDI upper bound for each prob
- Raises:
ValueErrorIf data has no date dimension (e.g., after “all_time” aggregation)
Examples
>>> df = mmm.summary.change_over_time() >>> df = mmm.summary.change_over_time(frequency="monthly") >>> df = mmm.summary.change_over_time(hdi_probs=[0.80, 0.94])