pandas.Index.values — pandas 3.0.0rc0+33.g1fd184de2a documentation (original) (raw)

property Index.values[source]#

Return an array representing the data in the Index.

Warning

We recommend using Index.array orIndex.to_numpy(), depending on whether you need a reference to the underlying data or a NumPy array.

Changed in version 3.0.0: The returned array is read-only.

Returns:

array: numpy.ndarray or ExtensionArray

Examples

For pandas.Index:

idx = pd.Index([1, 2, 3]) idx Index([1, 2, 3], dtype='int64') idx.values array([1, 2, 3])

For pandas.IntervalIndex:

idx = pd.interval_range(start=0, end=5) idx.values [(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]] Length: 5, dtype: interval[int64, right]