pandas.Index.get_level_values
-
Index.get_level_values(level)
[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 compatability.
Parameters: -
level : int or str
-
It is either the integer position or the name of the level.
Returns: -
values : Index
-
Calling object, as there is only one level in the Index.
See also
-
MultiIndex.get_level_values
- Get values for a level of a MultiIndex.
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')
Get level values by supplying
level
as integer:>>> idx.get_level_values(0) Index(['a', 'b', 'c'], dtype='object')
-
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.Index.get_level_values.html