atoti.measure module

class atoti.measure.Measure

Bases: atoti._bitwise_operators_only.BitwiseOperatorsOnly

A measure is a mostly-numeric data value, computed on demand for aggregation purposes.

Measures can be compared to other objects, such as a literal value, a Level, or another measure. The returned measure represents the outcome of the comparison and this measure can be used as a condition. If the measure’s value is None when evaluating a conditon, the returned value will be False.

Example

>>> df = pd.DataFrame(
...     columns=["Id", "Value", "Threshold"],
...     data=[
...         (0, 1.0, 5.0),
...         (1, 2.0, None),
...         (2, 3.0, 3.0),
...         (3, 4.0, None),
...         (4, 5.0, 1.0),
...     ],
... )
>>> store = session.read_pandas(df, keys=["Id"], store_name="Measure example")
>>> cube = session.create_cube(store)
>>> lvl, m = cube.levels, cube.measures
>>> m["Condition"] = m["Value.SUM"] > m["Threshold.SUM"]
>>> cube.query(m["Condition"], levels=lvl["Id"])
   Condition
Id
0      False
1      False
2      False
3      False
4       True
class atoti.measure.MeasureConvertible

Bases: atoti._bitwise_operators_only.BitwiseOperatorsOnly

Instances of this class can be converted to measures.