Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: update the Series.view docstring #20220

Merged
merged 3 commits into from
Mar 11, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move comparison with numpy.ndarray.view to Notes
  • Loading branch information
villasv committed Mar 11, 2018
commit cffd04b379d3c885bd9b00b8dff46ce9ff15635f
16 changes: 10 additions & 6 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,6 @@ def view(self, dtype=None):
type. The new data type must preserve the same size in bytes as to not
cause index misalignment.

Series are instantiated with `dtype=float64` by default, so unlike
`numpy.array.view()` this function will not try to preserve the current
Series data type.

Parameters
----------
dtype : data type
Expand All @@ -571,7 +567,15 @@ def view(self, dtype=None):

See Also
--------
numpy.ndarray.view : Return a new view of the same data in memory.
numpy.ndarray.view : Equivalent numpy function to create a new view of
the same data in memory.

Notes
-----
Series are instantiated with `dtype=float64` by default. While
`numpy.ndarray.view()` will return a view with the same data type as
the original array, Series.view() will try using `float64` and may fail
if the original data type size in bytes is not the same.

Examples
--------
Expand All @@ -584,7 +588,7 @@ def view(self, dtype=None):
4 2
dtype: int8

The 8 bit signed integer representation of `-1` is `0b10000001`, but
The 8 bit signed integer representation of `-1` is `0b11111111`, but
the same bytes represent 255 if read as an 8 bit unsigned integer:

>>> us = s.view('uint8')
Expand Down