atoti.hierarchy module¶
-
class
atoti.hierarchy.
Hierarchy
(_name, _levels, _dimension, _slicing, _cube, _java_api, _visible)¶ Bases:
atoti._base._base_hierarchy.BaseHierarchy
[Mapping
[str
,atoti.level.Level
]]Hierarchy of a Cube.
-
isin
(*member_paths)¶ Return a condition to check that the hierarchy is on one of the given members.
Considering
hierarchy_1
containinglevel_1
andlevel_2
,hierarchy_1.isin((a,), (b, x))
is equivalent to(level_1 == a) OR ((level_1 == b) AND (level_2 == x))
.- Parameters
members – One or more members expressed as tuples on which the hierarchy should be. Each element in a tuple corresponds to a level of the hierarchy, from the shallowest to the deepest.
Example
>>> df = pd.DataFrame( ... columns=["Country", "City", "Price"], ... data=[ ... ("Germany", "Berlin", 150.0), ... ("Germany", "Hamburg", 120.0), ... ("United Kingdom", "London", 240.0), ... ("United States", "New York", 270.0), ... ("France", "Paris", 200.0), ... ], ... ) >>> store = session.read_pandas( ... df, keys=["Country", "City"], store_name="isin example" ... ) >>> cube = session.create_cube(store) >>> h, lvl, m = cube.hierarchies, cube.levels, cube.measures >>> h["Geography"] = [lvl["Country"], lvl["City"]] >>> m["Price.SUM in Germany and Paris"] = tt.filter( ... m["Price.SUM"], ... h["Geography"].isin(("Germany",), ("France", "Paris")), ... ) >>> cube.query( ... m["Price.SUM"], ... m["Price.SUM in Germany and Paris"], ... levels=lvl["Geography", "City"], ... ) Price.SUM Price.SUM in Germany and Paris Country City France Paris 200.00 200.00 Germany Berlin 150.00 150.00 Hamburg 120.00 120.00 United Kingdom London 240.00 United States New York 270.00
- Return type
HierarchyIsInCondition
-