8000 DEPR: MultiIndex.to_hierarchical by KalyanGokhale · Pull Request #21613 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 8 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
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
Updated for comments
MItoHier
  • Loading branch information
KalyanGokhale committed Jun 26, 2018
commit 1d2eb264970ca631f0e3baef0556412ff72dd227
1 change: 0 additions & 1 deletion pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ class MultiIndex(Index):
from_product
set_levels
set_labels
to_hierarchical
to_frame
is_lexsorted
sortlevel
Expand Down
1 change: 1 addition & 0 deletions pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ def to_frame(self, filter_observations=True):
data[item] = self[item].values.ravel()[selector]

def construct_multi_parts(idx, n_repeat, n_shuffle=1):
# Replicates and shuffles MultiIndex, returns individual attributes
labels = [np.repeat(x, n_repeat) for x in idx.labels]
# Assumes that each label is divisible by n_shuffle
labels = [x.reshape(n_shuffle, -1).ravel(order='F')
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/indexes/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1673,10 +1673,9 @@ def test_to_frame(self):
tm.assert_frame_equal(result, expected)

def test_to_hierarchical(self):
# GH21613
index = MultiIndex.from_tuples([(1, 'one'), (1, 'two'), (2, 'one'), (
2, 'two')])
# 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']],
Expand Down
0