Documentation Index
Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
Use this file to discover all available pages before exploring further.
Hierarchy.isin(*members: ScalarConstantT_co) → RelationalCondition[TypeAliasForwardRef, Literal[‘EQ’], +ScalarConstantT_co]
Hierarchy.isin(*member_paths: tuple[ScalarConstantT_co, …]) → HierarchyMembershipCondition[Literal[‘IN’], +ScalarConstantT_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 to False 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'