Skip to content

Commit 128832f

Browse files
authored
TST: add test for last() on dataframe grouped by on boolean column (#46409) (#47736)
* TST: add test for last method on dataframe grouped by on boolean column (#46409) * TST: add test for last method on dataframe grouped by on boolean column (#46409) * BUG: PeriodIndex fails to handle NA, rather than putting NaT in its place (#46673) * BUG: PeriodIndex fails to handle NA, rather than putting NaT in its place (#46673) * BUG: PeriodIndex fails to handle NA, rather than putting NaT in its place (#46673)
1 parent 089f7f8 commit 128832f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/frame/methods/test_dtypes.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import timedelta
22

33
import numpy as np
4+
import pytest
45

56
from pandas.core.dtypes.dtypes import DatetimeTZDtype
67

@@ -79,6 +80,20 @@ def test_dtypes_are_correct_after_column_slice(self):
7980
Series({"a": np.float_, "b": np.float_, "c": np.float_}),
8081
)
8182

83+
@pytest.mark.parametrize(
84+
"data",
85+
[pd.NA, True],
86+
)
87+
def test_dtypes_are_correct_after_groupby_last(self, data):
88+
# GH46409
89+
df = DataFrame(
90+
{"id": [1, 2, 3, 4], "test": [True, pd.NA, data, False]}
91+
).convert_dtypes()
92+
result = df.groupby("id").last().test
93+
expected = df.set_index("id").test
94+
assert result.dtype == pd.BooleanDtype()
95+
tm.assert_series_equal(expected, result)
96+
8297
def test_dtypes_gh8722(self, float_string_frame):
8398
float_string_frame["bool"] = float_string_frame["A"] > 0
8499
result = float_string_frame.dtypes

0 commit comments

Comments
 (0)