Distribution Metrics
ACV (All Commodity Volume) metric.
ACV measures total dollar sales across all products in a set of stores, expressed in millions ($MM).
Acv
Calculates ACV (All Commodity Volume) for a set of stores.
ACV represents total dollar sales across all products, expressed in millions ($MM). NaN values in the spend column are excluded from the sum.
Results are accessible via the table attribute (ibis Table) or the df property
(materialized pandas DataFrame).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df |
DataFrame | Table
|
Transaction data containing at least a unit_spend column. |
required |
group_by |
str | list[str] | None
|
Optional column(s) to group the ACV calculation by (e.g., store_id). Defaults to None for total ACV. |
None
|
acv_scale_factor |
float
|
Factor to scale the ACV result (default is 1,000,000 for $MM). |
1000000
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If df is not a pandas DataFrame or an Ibis Table. |
ValueError
|
If required columns are missing from the data or if acv_scale_factor is not positive. |
Source code in pyretailscience/metrics/distribution/acv.py
df: pd.DataFrame
property
Returns the materialized pandas DataFrame of ACV results.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with ACV values. Cached after first access. |
__init__(df, group_by=None, acv_scale_factor=1000000)
Initializes the ACV calculation.