-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DEPR: Deprecate inplace param in MultiIndex.set_codes and MultiIndex.set_levels #35626
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
jreback
merged 5 commits into
pandas-dev:master
from
topper-123:deprecate_MultiIndex_inplace
Aug 10, 2020
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
|
@@ -740,7 +740,7 @@ def _set_levels( | |
self._tuples = None | ||
self._reset_cache() | ||
|
||
def set_levels(self, levels, level=None, inplace=False, verify_integrity=True): | ||
def set_levels(self, levels, level=None, inplace=None, verify_integrity=True): | ||
""" | ||
Set new levels on MultiIndex. Defaults to returning new index. | ||
|
||
|
@@ -752,6 +752,8 @@ def set_levels(self, levels, level=None, inplace=False, verify_integrity=True): | |
Level(s) to set (None for all levels). | ||
inplace : bool | ||
If True, mutates in place. | ||
|
||
.. deprecated:: 1.2.0 | ||
verify_integrity : bool, default True | ||
If True, checks that levels and codes are compatible. | ||
|
||
|
@@ -822,6 +824,15 @@ def set_levels(self, levels, level=None, inplace=False, verify_integrity=True): | |
>>> idx.set_levels([['a', 'b', 'c'], [1, 2, 3, 4]], level=[0, 1]).levels | ||
FrozenList([['a', 'b', 'c'], [1, 2, 3, 4]]) | ||
""" | ||
if inplace is not None: | ||
warnings.warn( | ||
"inplace is deprecated and will be removed in a future version.", | ||
FutureWarning, | ||
stacklevel=2, | ||
) | ||
else: | ||
inplace = False | ||
|
||
if is_list_like(levels) and not isinstance(levels, Index): | ||
levels = list(levels) | ||
|
||
|
@@ -898,7 +909,7 @@ def _set_codes( | |
self._tuples = None | ||
self._reset_cache() | ||
|
||
def set_codes(self, codes, level=None, inplace=False, verify_integrity=True): | ||
def set_codes(self, codes, level=None, inplace=None, verify_integrity=True): | ||
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. typing these would be good at some point |
||
""" | ||
Set new codes on MultiIndex. Defaults to returning new index. | ||
|
||
|
@@ -914,6 +925,8 @@ def set_codes(self, codes, level=None, inplace=False, verify_integrity=True): | |
Level(s) to set (None for all levels). | ||
inplace : bool | ||
If True, mutates in place. | ||
|
||
.. deprecated:: 1.2.0 | ||
verify_integrity : bool (default True) | ||
If True, checks that levels and codes are compatible. | ||
|
||
|
@@ -958,6 +971,15 @@ def set_codes(self, codes, level=None, inplace=False, verify_integrity=True): | |
(1, 'two')], | ||
names=['foo', 'bar']) | ||
""" | ||
if inplace is not None: | ||
warnings.warn( | ||
"inplace is deprecated and will be removed in a future version.", | ||
FutureWarning, | ||
stacklevel=2, | ||
) | ||
else: | ||
inplace = False | ||
|
||
if level is not None and not is_list_like(level): | ||
if not is_list_like(codes): | ||
raise TypeError("Codes must be list-like") | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove the inplace ref