Series.array
The ExtensionArray of the data backing this Series or Index.
New in version 0.24.0.
Returns: |
|
---|
See also
Index.to_numpy
Series.to_numpy
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 a arrays.NumpyExtensionArray
wrapping the actual ndarray stored within. If you absolutely need a NumPy array (possibly with copying / coercing data), then use Series.to_numpy()
instead.
For regular NumPy types like int, and float, a PandasArray is returned.
>>> pd.Series([1, 2, 3]).array <PandasArray> [1, 2, 3] Length: 3, dtype: int64
For extension types, like Categorical, the actual ExtensionArray is returned
>>> ser = pd.Series(pd.Categorical(['a', 'b', 'a'])) >>> ser.array [a, b, a] Categories (2, object): [a, b]
© 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.25.0/reference/api/pandas.Series.array.html