Skip to content

Commit fa81608

Browse files
committed
Refinements
1 parent dfb5e56 commit fa81608

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pandas/core/groupby/ops.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
ensure_platform_int,
4444
ensure_uint64,
4545
is_1d_only_ea_dtype,
46+
is_string_dtype,
4647
)
4748
from pandas.core.dtypes.missing import (
4849
isna,
@@ -959,12 +960,10 @@ def agg_series(
959960
npvalues = lib.maybe_convert_objects(result, try_float=False)
960961

961962
if isinstance(obj._values, ArrowExtensionArray):
962-
from pandas.core.dtypes.common import is_string_dtype
963-
964963
# When obj.dtype is a string, any object can be cast. Only do so if the
965964
# UDF returned strings or NA values.
966-
if not is_string_dtype(obj.dtype) or is_string_dtype(
967-
npvalues[~isna(npvalues)]
965+
if not is_string_dtype(obj.dtype) or lib.is_string_array(
966+
npvalues, skipna=True
968967
):
969968
out = maybe_cast_pointwise_result(
970969
npvalues, obj.dtype, numeric_only=True, same_dtype=preserve_dtype

0 commit comments

Comments
 (0)