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_col |
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 openretailscience/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_col=None, acv_scale_factor=1000000)
Initializes the ACV calculation.
Source code in openretailscience/metrics/distribution/acv.py
% of Stores (Numeric Distribution) metric.
% of Stores measures the share of total stores in the dataset that sell a given product. Every store counts equally regardless of its sales volume.
PctOfStores
Calculates the percentage of stores selling each product.
This is the simplest, unweighted distribution metric (numeric distribution). It answers the question: "What fraction of stores carry this product?"
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-level data containing at least store_id and product_id columns. |
required |
product_col |
str | list[str] | None
|
Column(s) defining product granularity.
Defaults to |
None
|
group_col |
str | list[str] | None
|
Additional grouping dimensions
(e.g., |
None
|
within_group |
bool
|
Controls the denominator when |
False
|
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 product_col appears in group_col. |
Source code in openretailscience/metrics/distribution/pct_of_stores.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
df: pd.DataFrame
property
Returns the materialized pandas DataFrame of % of Stores results.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with % of stores values. Cached after first access. |
__init__(df, *, product_col=None, group_col=None, within_group=False)
Initializes the % of Stores calculation.