Series.__array__(self, dtype=None) [source]
Return the values as a NumPy array.
Users should not call this directly. Rather, it is invoked by numpy.array() and numpy.asarray().
| Parameters: |
|
|---|---|
| Returns: |
|
See also
array
Series.array
Series.to_numpy
>>> ser = pd.Series([1, 2, 3]) >>> np.asarray(ser) array([1, 2, 3])
For timezone-aware data, the timezones may be retained with dtype='object'
>>> tzser = pd.Series(pd.date_range('2000', periods=2, tz="CET"))
>>> np.asarray(tzser, dtype="object")
array([Timestamp('2000-01-01 00:00:00+0100', tz='CET', freq='D'),
Timestamp('2000-01-02 00:00:00+0100', tz='CET', freq='D')],
dtype=object)
Or the values may be localized to UTC and the tzinfo discared with dtype='datetime64[ns]'
>>> np.asarray(tzser, dtype="datetime64[ns]") # doctest: +ELLIPSIS
array(['1999-12-31T23:00:00.000000000', ...],
dtype='datetime64[ns]')
© 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