We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bbfa399 commit 3db460cCopy full SHA for 3db460c
pandas/tests/groupby/test_nth.py
@@ -140,6 +140,18 @@ def test_first_last_nth_dtypes(df_mixed_floats):
140
assert f.dtype == "int64"
141
142
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
155
def test_first_strings_timestamps():
156
# GH 11244
157
test = pd.DataFrame(
0 commit comments