Skip to content

Commit e0bdfa7

Browse files
committed
TST: Test for tuples in columns, fixes to previous tests
1 parent 74f91e0 commit e0bdfa7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pandas/tests/groupby/test_grouping.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,18 @@ def test_groupby_multiindex_tuple(self):
366366
result = df.groupby(('b', 1)).groups
367367
tm.assert_dict_equal(expected, result)
368368

369-
df2 = pd.DataFrame([[1, 2, 3, 4], [3, 4, 5, 6], [1, 4, 2, 3]],
369+
df2 = pd.DataFrame(df.values,
370370
columns=pd.MultiIndex.from_arrays(
371371
[['a', 'b', 'b', 'c'],
372372
['d', 'd', 'e', 'e']]))
373-
df2.groupby([('b', 'd')]).groups
374-
expected = df.groupby([('b', 'd')]).groups
375-
result = df.groupby(('b', 'd')).groups
373+
expected = df2.groupby([('b', 'd')]).groups
374+
result = df.groupby(('b', 1)).groups
375+
tm.assert_dict_equal(expected, result)
376+
377+
df3 = pd.DataFrame(df.values,
378+
columns=[('a', 'd'), ('b', 'd'), ('b', 'e'), 'c'])
379+
expected = df3.groupby([('b', 'd')]).groups
380+
result = df.groupby(('b', 1)).groups
376381
tm.assert_dict_equal(expected, result)
377382

378383
@pytest.mark.parametrize('sort', [True, False])

0 commit comments

Comments
 (0)