Skip to content

Commit

Permalink
Updated test_frame_describe_multikey to remove duplicate MultiIndex…
Browse files Browse the repository at this point in the history
… levels
  • Loading branch information
cmazzullo committed Dec 1, 2017
1 parent 386daaf commit c169645
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pandas/tests/groupby/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ def test_series_index_name(self):
result = grouped.agg(lambda x: x.mean())
assert result.index.name == 'A'


def test_frame_describe_multikey(self):
grouped = self.tsframe.groupby([lambda x: x.year, lambda x: x.month])
result = grouped.describe()
desc_groups = []
for col in self.tsframe:
group = grouped[col].describe()
group_col = pd.MultiIndex([[col] * len(group.columns),
group.columns],
[[0] * len(group.columns),
range(len(group.columns))])
# GH 17464 - Remove duplicate MultiIndex levels
group_col = pd.MultiIndex(
levels=[[col], group.columns],
labels=[[0] * len(group.columns), range(len(group.columns))])
group = pd.DataFrame(group.values,
columns=group_col,
index=group.index)
Expand All @@ -67,8 +68,10 @@ def test_frame_describe_multikey(self):
'C': 1, 'D': 1}, axis=1)
result = groupedT.describe()
expected = self.tsframe.describe().T
expected.index = pd.MultiIndex([[0, 0, 1, 1], expected.index],
[range(4), range(len(expected.index))])
# GH 17464 - Remove duplicate MultiIndex levels
expected.index = pd.MultiIndex(
levels=[[0, 1], expected.index],
labels=[[0, 0, 1, 1], range(len(expected.index))])
tm.assert_frame_equal(result, expected)

def test_frame_describe_tupleindex(self):
Expand Down

0 comments on commit c169645

Please sign in to comment.