-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
DEPR: MultiIndex.to_hierarchical #21613
Conversation
MItoHier
MItoHier
Codecov Report
@@ Coverage Diff @@
## master #21613 +/- ##
==========================================
+ Coverage 91.9% 91.91% +<.01%
==========================================
Files 153 153
Lines 49547 49534 -13
==========================================
- Hits 45537 45527 -10
+ Misses 4010 4007 -3
Continue to review full report at Codecov.
|
pandas/tests/indexes/test_multi.py
Outdated
# GH21613 | ||
# .to_hierarchical will be deprecated | ||
with tm.assert_produces_warning(FutureWarning): | ||
result = index.to_hierarchical(2) |
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 don't need the result =
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.
Thanks - yes had missed it - will update together along with other comments
@@ -1704,6 +1704,11 @@ def test_to_hierarchical(self): | |||
tm.assert_index_equal(result, expected) |
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 need to catch all uses of to_hierarchical (or you get the warnings)
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.
Thanks - not sure if I understand.
The only use of to_hierarchical
was in pandas/core/panel.py
- this has been substituted.
This existing test is specifically for to_hierarchical
- which can be removed once this method is removed in a future version - should these tests be removed as part of this PR?
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.
@@ -1182,6 +1182,8 @@ def to_frame(self, index=True): | |||
|
|||
def to_hierarchical(self, n_repeat, n_shuffle=1): | |||
""" |
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.
to_hierarchical is listed elsewhere in this file in a doc-string
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.
Thanks - it is mentioned as a part of enumeration of methods of MultiIndex
- should it be removed?
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.
yes
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.
Thanks - updated for all of the latest review comments
MItoHier
MItoHier
MItoHier
@@ -1182,6 +1182,8 @@ def to_frame(self, index=True): | |||
|
|||
def to_hierarchical(self, n_repeat, n_shuffle=1): | |||
""" |
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.
yes
@@ -948,10 +948,13 @@ def to_frame(self, filter_observations=True): | |||
data[item] = self[item].values.ravel()[selector] | |||
|
|||
def construct_multi_parts(idx, n_repeat, n_shuffle=1): | |||
axis_idx = idx.to_hierarchical(n_repeat, n_shuffle) |
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.
can you provide a 1-liner what this method is doing
pandas/tests/indexes/test_multi.py
Outdated
@@ -1675,15 +1675,19 @@ def test_to_frame(self): | |||
def test_to_hierarchical(self): | |||
index = MultiIndex.from_tuples([(1, 'one'), (1, 'two'), (2, 'one'), ( | |||
2, 'two')]) | |||
result = index.to_hierarchical(3) | |||
# GH21613 | |||
# Suppressed deprecation warnings in this original test |
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.
these comments are not needed, move the gh issue number to the top of this method
MItoHier
thanks! |
xref #18262
git diff upstream/master -u -- "*.py" | flake8 --diff