Table Of Contents

Search

Enter search terms or a module, class or function name.

pandas.Index.array

Index.array

The actual Array backing this Series or Index.

New in version 0.24.0.

Returns:

array : numpy.ndarray or ExtensionArray

This is the actual array stored within this object. This differs from .values which may require converting the data to a different form.

See also

Index.to_numpy
Similar method that always returns a NumPy array.
Series.to_numpy
Similar method that always returns a NumPy array.

Notes

This table lays out the different array types for each extension dtype within pandas.

dtype array type
category Categorical
period PeriodArray
interval IntervalArray
IntegerNA IntegerArray
datetime64[ns, tz] DatetimeArray

For any 3rd-party extension types, the array type will be an ExtensionArray.

For all remaining dtypes .array will be the numpy.ndarray stored within. If you absolutely need a NumPy array (possibly with copying / coercing data), then use Series.to_numpy() instead.

Note

.array will always return the underlying object backing the Series or Index. If a future version of pandas adds a specialized extension type for a data type, then the return type of .array for that data type will change from an object-dtype ndarray to the new ExtensionArray.

Examples

>>> ser = pd.Series(pd.Categorical(['a', 'b', 'a']))
>>> ser.array
[a, b, a]
Categories (2, object): [a, b]
Scroll To Top