> ## 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.

# atoti.hierarchies.Hierarchies

### *final class* atoti.hierarchies.Hierarchies

Manage the hierarchies of a [`Cube`](./atoti.cube#atoti.Cube).

### Example

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> prices_df = pd.DataFrame(
...     columns=["Nation", "City", "Color", "Price"],
...     data=[
...         ("France", "Paris", "red", 20.0),
...         ("France", "Lyon", "blue", 15.0),
...         ("France", "Toulouse", "green", 10.0),
...         ("UK", "London", "red", 20.0),
...         ("UK", "Manchester", "blue", 15.0),
...     ],
... )
>>> table = session.read_pandas(prices_df, table_name="Prices")
>>> cube = session.create_cube(table, mode="manual")
>>> h = cube.hierarchies
>>> h["Nation"] = {"Nation": table["Nation"]}
>>> list(h)
[('Prices', 'Nation')]
```

A hierarchy can be renamed by copying it and deleting the old one:

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> h["Country"] = h["Nation"]
>>> del h["Nation"]
>>> list(h)
[('Prices', 'Country')]
>>> list(h["Country"])
['Nation']
```

[`update()`](https://docs.python.org/3/library/stdtypes.html#dict.update) can be used to batch hierarchy creation operations for improved performance:

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> h.update(
...     {
...         ("Geography", "Geography"): [table["Nation"], table["City"]],
...         "Color": {"Color": table["Color"]},
...     }
... )
>>> sorted(h)
[('Geography', 'Geography'), ('Prices', 'Color'), ('Prices', 'Country')]
```

<Callout icon="link">
  **See also**:
  [`Hierarchy`](./atoti.hierarchy#atoti.Hierarchy) to configure existing hierarchies.
</Callout>
