mario.CoreModel.get_index
- CoreModel.get_index(index, level='main', *, region=None, flat=False)#
Return one index level or the full index mapping for the database.
- Parameters:
index – Set name such as
RegionorSector. Pass"all"to retrieve every available set for the table type.level – Index variant to return, typically
"main"or"aggregated".region – Optional region whose members should be returned as a list. Available only for
level="main".flat – When True, explicitly return the union of distinct labels as a list even for a regional classification. Available only for
level="main"and mutually exclusive withregion.
- Returns:
For
level="main", a list when every region has the same members, otherwise{region: list_of_members}. Regions without members have an empty list. Global sets remain lists. Withindex="all", a dictionary of these results keyed by set name. Other index levels retain their existing representation.- Return type:
list | dict
The usual return value is an ordered list. For the special case of regional classifications, the result is a dictionary of lists:
db.get_index("Activity")
# Common classification: ["A1", "A2", ...]
# Regional classification: {"IT": ["A1"], "DE": ["A2", "A3"], ...}
Each set is checked independently. Equal counts alone do not imply a common classification. Differences in axis order alone do not require a dictionary; the common list retains the existing logical index order. Regions without members appear with an empty list.
Select one region, or explicitly request the union of distinct labels:
db.get_index("Activity", region="IT") # Always a list.
db.get_index("Activity", flat=True) # Union, always a list.
db.get_index("all") # Each set uses its own representation.
The union does not imply that all its members exist in every region. Use the regional view when validating region-item pairs.
Membership includes existing nodes with zero flows. Non-main levels, including aggregation DataFrames, retain their existing representation.