-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
DEPR: MultiIndex.to_hierarchical #21613
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
Changes from 1 commit
79d19e4
007f26f
cd78d93
8727f95
7aa3bbf
2e5a6da
3eedafc
1d2eb26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
MItoHier
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
with tm.assert_produces_warning(FutureWarning): | ||
result = index.to_hierarchical(3) | ||
expected = MultiIndex(levels=[[1, 2], ['one', 'two']], | ||
labels=[[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], | ||
[0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]]) | ||
tm.assert_index_equal(result, expected) | ||
assert result.names == index.names | ||
|
||
# K > 1 | ||
result = index.to_hierarchical(3, 2) | ||
with tm.assert_produces_warning(FutureWarning): | ||
result = index.to_hierarchical(3, 2) | ||
expected = MultiIndex(levels=[[1, 2], ['one', 'two']], | ||
labels=[[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], | ||
[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]]) | ||
|
@@ -1694,8 +1698,8 @@ def test_t 8000 o_hierarchical(self): | |
index = MultiIndex.from_tuples([(2, 'c'), (1, 'b'), | ||
(2, 'a'), (2, 'b')], | ||
names=['N1', 'N2']) | ||
|
||
result = index.to_hierarchical(2) | ||
with tm.assert_produces_warning(FutureWarning): | ||
result = index.to_hierarchical(2) | ||
expected = MultiIndex.from_tuples([(2, 'c'), (2, 'c'), (1, 'b'), | ||
(1, 'b'), | ||
(2, 'a'), (2, 'a'), | ||
|
@@ -1704,11 +1708,6 @@ def test_to_hierarchical(self): | |
tm.assert_index_equal(result, expected) | ||
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. 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 commentThe reason will be displayed to describe this comment to others. Learn more. Thanks - not sure if I understand. 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. |
||
assert result.names == index.names | ||
|
||
# GH21613 | ||
# .to_hierarchical will be deprecated | ||
with tm.assert_produces_warning(FutureWarning): | ||
result = index.to_hierarchical(2) | ||
|
||
def test_bounds(self): | ||
self.index._bounds | ||
|
||
|
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