You are viewing documentation about an older version (1.21.0). View latest version

modin.pandas.Index.get_level_values¶

Index.get_level_values(level: int | str) → Index[source]¶

Return an Index of values for requested level.

This is primarily useful to get an individual level of values from a MultiIndex, but is provided on Index as well for compatibility.

Parameters:

level (int or str) – It is either the integer position or the name of the level.

Returns:

self, since self only has one level

Return type:

Index

Notes

For Index, level should be 0, since there are no multiple levels.

Examples

>>> idx = pd.Index(list('abc'))
>>> idx
Index(['a', 'b', 'c'], dtype='object')
Copy

Get level values by supplying level as integer:

>>> idx.get_level_values(0)
Index(['a', 'b', 'c'], dtype='object')
Copy