Skip to content

Commit 3db460c

Browse files
TST: Groupby first/last/nth nan column test (#33627)
1 parent bbfa399 commit 3db460c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/groupby/test_nth.py

+12
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ def test_first_last_nth_dtypes(df_mixed_floats):
140140
assert f.dtype == "int64"
141141

142142

143+
def test_first_last_nth_nan_dtype():
144+
# GH 33591
145+
df = pd.DataFrame({"data": ["A"], "nans": pd.Series([np.nan], dtype=object)})
146+
147+
grouped = df.groupby("data")
148+
expected = df.set_index("data").nans
149+
tm.assert_series_equal(grouped.nans.first(), expected)
150+
tm.assert_series_equal(grouped.nans.last(), expected)
151+
tm.assert_series_equal(grouped.nans.nth(-1), expected)
152+
tm.assert_series_equal(grouped.nans.nth(0), expected)
153+
154+
143155
def test_first_strings_timestamps():
144156
# GH 11244
145157
test = pd.DataFrame(

0 commit comments

Comments
 (0)