Skip to content
Merged
Changes from all commits
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
17 changes: 17 additions & 0 deletions pandas/tests/groupby/test_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,23 @@ def test_grouper_creation_bug3(self):
expected = ser.groupby(level="one").sum()
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize("func", [False, True])
def test_grouper_returning_tuples(self, func):
# GH 22257 , both with dict and with callable
df = DataFrame({"X": ["A", "B", "A", "B"], "Y": [1, 4, 3, 2]})
mapping = dict(zip(range(4), [("C", 5), ("D", 6)] * 2))

if func:
gb = df.groupby(by=lambda idx: mapping[idx], sort=False)
else:
gb = df.groupby(by=mapping, sort=False)

name, expected = next(iter(gb))
assert name == ("C", 5)
result = gb.get_group(name)

tm.assert_frame_equal(result, expected)

def test_grouper_column_and_index(self):
# GH 14327

Expand Down