-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
DEPR: Deprecate Series.view #56054
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
Merged
Merged
DEPR: Deprecate Series.view #56054
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3ad7148
DEP: Deprecate Series.view
phofl f82034d
DEP: Deprecate Series.view
phofl b66c3a9
Merge branch 'main' into depview
phofl e33095c
Update test_view.py
phofl 38379ac
Fix dep warnings
phofl 7854092
Fix view
phofl aa8809a
Merge branch 'main' into depview
phofl b3a85f3
Remove
phofl e5d525c
Update pandas/tests/groupby/test_timegrouper.py
phofl 4e42dd9
Update pandas/tests/series/test_constructors.py
phofl d9d6faa
Fix
phofl f98743f
Merge remote-tracking branch 'upstream/main' into depview
phofl 81a3356
Merge remote-tracking branch 'upstream/main' into depview
phofl c64dca9
Update pandas/core/series.py
phofl ef1290e
Move dep warning
phofl 8bd7b39
Merge remote-tracking branch 'upstream/main' into depview
phofl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -881,6 +881,10 @@ def view(self, dtype: Dtype | None = None) -> Series: | |
type. The new data type must preserve the same size in bytes as to not | ||
cause index misalignment. | ||
|
||
.. deprecated:: 2.2.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently this block needs to be placed between the short and extended summary, so after the first sentence above. Maybe somehow the first error is tripping up further checks ... |
||
``Series.view`` is deprecated and will be removed in a future version. | ||
Use :meth:`Series.astype` as an alternative to change the dtype. | ||
|
||
Parameters | ||
---------- | ||
dtype : data type | ||
|
@@ -906,38 +910,14 @@ def view(self, dtype: Dtype | None = None) -> Series: | |
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([-2, -1, 0, 1, 2], dtype='int8') | ||
>>> s | ||
0 -2 | ||
1 -1 | ||
2 0 | ||
3 1 | ||
4 2 | ||
dtype: int8 | ||
|
||
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') | ||
>>> us | ||
0 254 | ||
1 255 | ||
2 0 | ||
3 1 | ||
4 2 | ||
dtype: uint8 | ||
|
||
The views share the same underlying values: | ||
|
||
>>> us[0] = 128 | ||
>>> s | ||
0 -128 | ||
1 -1 | ||
2 0 | ||
3 1 | ||
4 2 | ||
dtype: int8 | ||
Use ``astype`` to change the dtype instead. | ||
""" | ||
warnings.warn( | ||
"Series.view is deprecated and will be removed in a future version. " | ||
"Use ``astype`` as an alternative to change the dtype.", | ||
FutureWarning, | ||
stacklevel=2, | ||
) | ||
# self.array instead of self._values so we piggyback on NumpyExtensionArray | ||
# implementation | ||
res_values = self.array.view(dtype) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.