Skip to content

Commit a7b8c1d

Browse files
authored
TST: add test for groupby with dropna=False on multi-index (#47717)
Update test_groupby_dropna.py
1 parent 5690e8f commit a7b8c1d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/groupby/test_groupby_dropna.py

+9
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,12 @@ def test_groupby_nan_included():
378378
tm.assert_numpy_array_equal(result_values, expected_values)
379379
assert np.isnan(list(result.keys())[2])
380380
assert list(result.keys())[0:2] == ["g1", "g2"]
381+
382+
383+
def test_groupby_drop_nan_with_multi_index():
384+
# GH 39895
385+
df = pd.DataFrame([[np.nan, 0, 1]], columns=["a", "b", "c"])
386+
df = df.set_index(["a", "b"])
387+
result = df.groupby(["a", "b"], dropna=False).first()
388+
expected = df
389+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)