Skip to content

Commit 6e61cf4

Browse files
authored
TST: Add test for groupby with datetime and NaT values (#61021)
1 parent c28c589 commit 6e61cf4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/groupby/test_groupby.py

+18
Original file line numberDiff line numberDiff line change
@@ -2978,3 +2978,21 @@ def test_groupby_multi_index_codes():
29782978

29792979
index = df_grouped.index
29802980
tm.assert_index_equal(index, MultiIndex.from_frame(index.to_frame()))
2981+
2982+
2983+
def test_groupby_datetime_with_nat():
2984+
# GH##35202
2985+
df = DataFrame(
2986+
{
2987+
"a": [
2988+
to_datetime("2019-02-12"),
2989+
to_datetime("2019-02-12"),
2990+
to_datetime("2019-02-13"),
2991+
pd.NaT,
2992+
],
2993+
"b": [1, 2, 3, 4],
2994+
}
2995+
)
2996+
grouped = df.groupby("a", dropna=False)
2997+
result = len(grouped)
2998+
assert result == 3

0 commit comments

Comments
 (0)