atoti.agg.mean()#

atoti.agg.mean(operand: LevelOrVariableColumnConvertible, /) MeasureDescription#
atoti.agg.mean(operand: VariableMeasureConvertible, /, *, scope: CumulativeScope | SiblingsScope | OriginScope) MeasureDescription

Return a measure equal to the mean of the passed measure across the specified scope.

Parameters:
  • operand – The measure or table column to aggregate.

  • scope – The aggregation scope.

Example

>>> df = pd.DataFrame(
...     columns=["id", "Quantity", "Price", "Other"],
...     data=[
...         ("a1", 100, 12.5, 1),
...         ("a2", 10, 43, 2),
...         ("a3", 1000, 25.9, 2),
...     ],
... )
>>> table = session.read_pandas(
...     df,
...     keys=["id"],
...     table_name="Product",
... )
>>> table.head().sort_index()
    Quantity  Price  Other
id
a1       100   12.5      1
a2        10   43.0      2
a3      1000   25.9      2
>>> cube = session.create_cube(table)
>>> m = cube.measures
>>> m["Quantity.MEAN"] = tt.agg.mean(table["Quantity"])
>>> cube.query(m["Quantity.MEAN"])
  Quantity.MEAN
0        370.00