pandas 1.4.2

ParametersReturns
__array__(self, dtype: 'npt.DTypeLike | None' = None) -> 'np.ndarray'

Users should not call this directly. Rather, it is invoked by numpy.array and numpy.asarray .

Parameters

dtype : str or numpy.dtype, optional

The dtype to use for the resulting NumPy array. By default, the dtype is inferred from the data.

Returns

numpy.ndarray

The values in the series converted to a numpy.ndarray with the specified dtype .

Return the values as a NumPy array.

See Also

Series.array

Zero-copy view to the array backing the Series.

Series.to_numpy

Series method for similar behavior.

array

Create a new array from data.

Examples

This example is valid syntax, but we were not able to check execution
>>> 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'

This example is valid syntax, but we were not able to check execution
>>> 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'), Timestamp('2000-01-02 00:00:00+0100', tz='CET')], dtype=object)

Or the values may be localized to UTC and the tzinfo discarded with dtype='datetime64[ns]'

This example is valid syntax, but we were not able to check execution
>>> np.asarray(tzser, dtype="datetime64[ns]")  # doctest: +ELLIPSIS
array(['1999-12-31T23:00:00.000000000', ...],
      dtype='datetime64[ns]')
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/series.py#825
type: <class 'function'>
Commit: