MultiIndex.
get_level_values
Return vector of label values for requested level, equal to the length of the index.
level is either the integer position of the level in the MultiIndex, or the name of the level.
level
Values is a level of this MultiIndex converted to a single Index (or subclass thereof).
Index
Examples
Create a MultiIndex:
>>> mi = pd.MultiIndex.from_arrays((list('abc'), list('def'))) >>> mi.names = ['level_1', 'level_2']
Get level values by supplying level as either integer or name:
>>> mi.get_level_values(0) Index(['a', 'b', 'c'], dtype='object', name='level_1') >>> mi.get_level_values('level_2') Index(['d', 'e', 'f'], dtype='object', name='level_2')