Skip to content

Commit ddff592

Browse files
committed
BUG: Aggregation on arrow array return same type.
Signed-off-by: Liang Yan <[email protected]>
1 parent 641427e commit ddff592

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pandas/core/groupby/ops.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
maybe_fill,
5353
)
5454

55+
import pandas as pd
5556
from pandas.core.frame import DataFrame
5657
from pandas.core.groupby import grouper
5758
from pandas.core.indexes.api import (
@@ -837,7 +838,11 @@ def agg_series(
837838
# test_groupby_empty_with_category gets here with self.ngroups == 0
838839
# and len(obj) > 0
839840

840-
if len(obj) > 0 and not isinstance(obj._values, np.ndarray):
841+
if (
842+
len(obj) > 0
843+
and not isinstance(obj._values, np.ndarray)
844+
and not isinstance(obj._values, pd.arrays.ArrowExtensionArray)
845+
):
841846
# we can preserve a little bit more aggressively with EA dtype
842847
# because maybe_cast_pointwise_result will do a try/except
843848
# with _from_sequence. NB we are assuming here that _from_sequence

0 commit comments

Comments
 (0)