atoti.Hierarchy.isin()#
- Hierarchy.isin(*members: ScalarT_co) RelationalCondition[TypeAliasForwardRef, Literal['EQ'], +ScalarT_co] #
- Hierarchy.isin(*member_paths: tuple[ScalarT_co, ...]) HierarchyIsInCondition[Literal['IS_IN'], +ScalarT_co]
Return a condition evaluating to
True
where this hierarchy’s current member (or its path) is included in the given members (or member_paths), and evaluating toFalse
elsewhere.- Parameters:
members_or_member_paths –
Either:
One or more members. In that case, all the hierarchy’s members are expected to be unique across all the levels of the hierarchy.
One or more member paths expressed as tuples of members starting from the top of the hierarchy.
Example
>>> df = pd.DataFrame( ... columns=["Country", "City", "Price"], ... data=[ ... ("Germany", "Berlin", 150.0), ... ("Germany", "Hamburg", 120.0), ... ("United Kingdom", "Bath", 240.0), ... ("United Kingdom", "London", 270.0), ... ], ... ) >>> table = session.read_pandas( ... df, keys={"Country", "City"}, table_name="Example" ... ) >>> cube = session.create_cube(table, mode="manual") >>> h = cube.hierarchies >>> h["Geography"] = [table["Country"], table["City"]]
Condition on members:
>>> h["Geography"].isin("Germany", "London") h['Example', 'Geography'].isin('Germany', 'London')
Condition on member paths:
>>> h["Geography"].isin(("Germany",), ("United Kingdom", "Bath")) h['Example', 'Geography'].isin(('Germany',), ('United Kingdom', 'Bath'))
Members and member paths cannot be mixed:
>>> h["Geography"].isin("Germany", ("United Kingdom", "Bath")) Traceback (most recent call last): ... ValueError: Expected either only members or only member paths but both were mixed: `('Germany', ('United Kingdom', 'Bath'))`.
Conditions on single members are normalized to equality conditions:
>>> h["Geography"].isin("Germany") h['Example', 'Geography'] == 'Germany'