Skip to content

TST: Groupby first/last/nth nan column test #33627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pandas/tests/groupby/test_nth.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ def test_first_last_nth_dtypes(df_mixed_floats):
assert f.dtype == "int64"


def test_first_last_nth_nan_dtype():
# GH 33591
df = pd.DataFrame({"data": ["A"], "nans": pd.Series([np.nan], dtype=object)})

grouped = df.groupby("data")
expected = df.set_index("data").nans
tm.assert_series_equal(grouped.nans.first(), expected)
tm.assert_series_equal(grouped.nans.last(), expected)
tm.assert_series_equal(grouped.nans.nth(-1), expected)
tm.assert_series_equal(grouped.nans.nth(0), expected)


def test_first_strings_timestamps():
# GH 11244
test = pd.DataFrame(
Expand Down