atoti.level module

class atoti.level.Level(_name, _column_name, _data_type, _hierarchy=None, _comparator=None)

Bases: atoti._base._base_level.BaseLevel, atoti.measure.MeasureConvertible

Level of a Hierarchy.

property comparator

Comparator of the level.

Return type

Optional[Comparator]

property data_type

Type of the level members.

Return type

DataType

property dimension

Name of the dimension holding the level.

Return type

str

property hierarchy

Name of the hierarchy holding the level.

Return type

str

isin(*members)

Return a condition to check that the level is on one of the given members.

level.isin(a, b) is equivalent to (level == a) OR (level == b).

Parameters

members (Any) – One or more members on which the level should be.

Example

>>> df = pd.DataFrame(
...     columns=["City", "Price"],
...     data=[
...         ("Berlin", 150.0),
...         ("London", 240.0),
...         ("New York", 270.0),
...         ("Paris", 200.0),
...     ],
... )
>>> store = session.read_pandas(
...     df, keys=["City"], store_name="isin example"
... )
>>> cube = session.create_cube(store)
>>> lvl, m = cube.levels, cube.measures
>>> m["Price.SUM in London and Paris"] = tt.filter(
...     m["Price.SUM"], lvl["City"].isin("London", "Paris")
... )
>>> cube.query(
...     m["Price.SUM"],
...     m["Price.SUM in London and Paris"],
...     levels=lvl["City"],
... )
         Price.SUM Price.SUM in London and Paris
City
Berlin      150.00
London      240.00                        240.00
New York    270.00
Paris       200.00                        200.00
Return type

LevelIsInCondition

property name

Name of the level.

Return type

str