set_panel
set_panel(df, *, entity=None, time=None, entity_name=None)Declare the panel’s entity, time (and optional entity_name) columns on df.
The ids are stored under df.attrs["geometrics_panel"] so that subsequent explore_* / analyze_* calls can omit them. Explicit arguments to those functions still take precedence.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | The panel data frame (modified in place — its attrs are updated and the same object is returned). |
required |
| entity | str | None | Name of the cross-sectional (unit) identifier column, or None to leave it unset. |
None |
| time | str | None | Name of the time identifier column, or None to leave it unset. |
None |
| entity_name | str | None | Name of a column holding a human-readable label for each unit (e.g. "country" when entity is an ISO code). When declared, figures render units as Name (id). None leaves it unset. |
None |
Returns
| Name | Type | Description |
|---|---|---|
| pandas.DataFrame | The same df, with df.attrs["geometrics_panel"] updated. |
Examples
Declare the panel once, then explore without repeating the ids:
import pandas as pd
import geometrics as gm
df = pd.DataFrame(
{
"region": ["A", "A", "B", "B"],
"year": [2000, 2001, 2000, 2001],
"gdp_pc": [1.0, 1.1, 2.0, 2.1],
}
)
df = gm.set_panel(df, entity="region", time="year")