Skip to content

TST: add test for last() on dataframe grouped by on boolean column (#46409) #47736

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 6 commits into from
Jul 18, 2022
16 changes: 16 additions & 0 deletions pandas/tests/frame/methods/test_dtypes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import timedelta

import numpy as np
import pytest

from pandas.core.dtypes.dtypes import DatetimeTZDtype

Expand Down Expand Up @@ -79,6 +80,21 @@ def test_dtypes_are_correct_after_column_slice(self):
Series({"a": np.float_, "b": np.float_, "c": np.float_}),
)

@pytest.mark.parametrize(
"data",
[
DataFrame({"id": [1, 2, 3, 4], "test": [True, pd.NA, pd.NA, False]}),
DataFrame({"id": [1, 2, 3, 4], "test": [True, pd.NA, True, False]}),
],
)
def test_dtypes_are_correct_after_groupby_last(self, data):
# GH46409
data = data.convert_dtypes()
result = data.groupby("id").last().test
expected = data.set_index("id").test
assert result.dtype == pd.BooleanDtype()
tm.assert_series_equal(expected, result)

def test_dtypes_gh8722(self, float_string_frame):
float_string_frame["bool"] = float_string_frame["A"] > 0
result = float_string_frame.dtypes
Expand Down