Skip to content

Commit

Permalink
docs(python): clarify "clones data" in to_numpy (#10095)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli authored Jul 26, 2023
1 parent 05bf5ab commit e6ea794
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3635,9 +3635,18 @@ def to_numpy(
use_pyarrow: bool = True,
) -> np.ndarray[Any, Any]:
"""
Convert this Series to numpy. This operation clones data but is completely safe.
Convert this Series to numpy.
If you want a zero-copy view and know what you are doing, use `.view()`.
This operation may clone 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 can't be zero-copied.
To ensure that no data is cloned, set ``zero_copy_only=True``.
Alternatively, if you want a zero-copy view and know what you are doing,
use `.view()`.
Parameters
----------
Expand Down

0 comments on commit e6ea794

Please sign in to comment.