Skip to content

Commit 6cd6069

Browse files
author
Khor Chean Wei
authored
Test case dataframe.groupby incorrect with multiindex and None value (#45982)
* Add test * Update test_indexing.py * Update test_indexing.py * Update pytest.raises * add match * change function
1 parent cf2dfa7 commit 6cd6069

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/groupby/test_indexing.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,19 @@ def test_groupby_duplicated_columns(func):
314314
[[1.5, 3.0, 1.5]], columns=["A", "B", "A"], index=pd.Index(["G"], name="C")
315315
)
316316
tm.assert_frame_equal(result, expected)
317+
318+
319+
def test_groupby_get_nonexisting_groups():
320+
# GH#32492
321+
df = pd.DataFrame(
322+
data={
323+
"A": ["a1", "a2", None],
324+
"B": ["b1", "b2", "b1"],
325+
"val": [1, 2, 3],
326+
}
327+
)
328+
grps = df.groupby(by=["A", "B"])
329+
330+
msg = "('a2', 'b1')"
331+
with pytest.raises(KeyError, match=msg):
332+
grps.get_group(("a2", "b1"))

0 commit comments

Comments
 (0)