allow_copy: bool = True,
writable: bool = False,
use_pyarrow: bool = True,
zero_copy_only: bool | None = None,
) ndarray[Any, Any][source]#

Convert this Series to a NumPy ndarray.

This operation may copy data, but is completely safe. Note that:

  • Data which is purely numeric AND without null values is not cloned

  • Floating point nan values can be zero-copied

  • Booleans cannot be zero-copied

To ensure that no data is copied, set allow_copy=False.


Allow memory to be copied to perform the conversion. If set to False, causes conversions that are not zero-copy to fail.


Ensure the resulting array is writable. This will force a copy of the data if the array was created without copy, as the underlying Arrow data is immutable.


Use pyarrow.Array.to_numpy for the conversion to NumPy.


Raise an exception if the conversion to a NumPy would require copying the underlying data. Data copy occurs, for example, when the Series contains nulls or non-numeric types.


>>> s = pl.Series("a", [1, 2, 3])
>>> arr = s.to_numpy()
>>> arr  
array([1, 2, 3], dtype=int64)
>>> type(arr)
<class 'numpy.ndarray'>