Skip to content

TST: Group by callable test #55926

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 2 commits into from
Nov 13, 2023
Merged
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
lint
  • Loading branch information
quangngd committed Nov 12, 2023
commit 2b3c2814a0ab4d373da28dfb294fd1bad2ed9a38
10 changes: 5 additions & 5 deletions pandas/tests/groupby/test_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,19 @@ def test_grouper_creation_bug3(self):
expected = ser.groupby(level="one").sum()
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize('func', [False, True])
@pytest.mark.parametrize("func", [False, True])
def test_grouper_returning_tuples(self, func):
# GH 22257 , both with dict and with callable
df = pd.DataFrame({'X': ['A', 'B', 'A', 'B'], 'Y': [1, 4, 3, 2]})
mapping = dict(zip(range(4), [('C', 5), ('D', 6)] * 2))
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 = list(gb)[0]
assert name == ('C', 5)
name, expected = next(iter(gb))
assert name == ("C", 5)
result = gb.get_group(name)

tm.assert_frame_equal(result, expected)
Expand Down