Skip to content

Commit 35a17b9

Browse files
committed
add the test case for grouping bug
1 parent b983366 commit 35a17b9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/groupby/test_groupby.py

+21
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import re
55

66
import numpy as np
7+
import pyarrow as pa
78
import pytest
89

910
from pandas.errors import SpecificationError
1011
import pandas.util._test_decorators as td
1112

13+
from pandas.core.dtypes.dtypes import ArrowDtype
14+
1215
import pandas as pd
1316
from pandas import (
1417
Categorical,
@@ -2978,3 +2981,21 @@ def test_groupby_multi_index_codes():
29782981

29792982
index = df_grouped.index
29802983
tm.assert_index_equal(index, MultiIndex.from_frame(index.to_frame()))
2984+
2985+
2986+
def test_groupby_arrow_dictionary_na():
2987+
# Arrange
2988+
df = DataFrame(
2989+
{"A": ["a1", pd.NA]}, dtype=ArrowDtype(pa.dictionary(pa.int32(), pa.utf8()))
2990+
)
2991+
2992+
# Act
2993+
result = df.groupby("A", dropna=False)[["A"]].first()
2994+
2995+
# Assert
2996+
expected = DataFrame(
2997+
{"A": ["a1", pd.NA]},
2998+
index=Index(["a1", pd.NA], name="A"),
2999+
dtype=ArrowDtype(pa.dictionary(pa.int32(), pa.utf8())),
3000+
)
3001+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)