Skip to content

Commit c9282de

Browse files
committed
TST: Add test for value_counts with Arrow dictionary dtype (#60563)
1 parent 1e4e2f4 commit c9282de

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/extension/test_arrow.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,3 +3511,20 @@ def test_map_numeric_na_action():
35113511
result = ser.map(lambda x: 42, na_action="ignore")
35123512
expected = pd.Series([42.0, 42.0, np.nan], dtype="float64")
35133513
tm.assert_series_equal(result, expected)
3514+
3515+
3516+
def test_categorical_from_arrow_dictionary():
3517+
# GH 60563
3518+
df = pd.DataFrame(
3519+
{"A": ["a1", "a2"]}, dtype=ArrowDtype(pa.dictionary(pa.int32(), pa.utf8()))
3520+
)
3521+
result = df.value_counts(dropna=False)
3522+
expected = pd.Series(
3523+
[1, 1],
3524+
index=pd.MultiIndex.from_arrays(
3525+
[pd.Index(["a1", "a2"], dtype=ArrowDtype(pa.string()), name="A")]
3526+
),
3527+
name="count",
3528+
dtype="int64",
3529+
)
3530+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)