Skip to content

Commit b48635e

Browse files
authored
TST: added test for groupby when calling first, last, nth (GH29645) (#43358)
1 parent c7d98e1 commit b48635e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/groupby/test_nth.py

+17
Original file line numberDiff line numberDiff line change
@@ -689,3 +689,20 @@ def test_first_multi_key_groupbby_categorical():
689689
[(1, 100), (1, 200), (2, 100)], names=["A", "B"]
690690
)
691691
tm.assert_frame_equal(result, expected)
692+
693+
694+
@pytest.mark.parametrize("method", ["first", "last", "nth"])
695+
def test_groupby_last_first_nth_with_none(method, nulls_fixture):
696+
# GH29645
697+
expected = Series(["y"])
698+
data = Series(
699+
[nulls_fixture, nulls_fixture, nulls_fixture, "y", nulls_fixture],
700+
index=[0, 0, 0, 0, 0],
701+
).groupby(level=0)
702+
703+
if method == "nth":
704+
result = getattr(data, method)(3)
705+
else:
706+
result = getattr(data, method)()
707+
708+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)