diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 5674c118f63d6..c5faa432cb494 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -107,7 +107,6 @@ ensure_platform_int, infer_dtype_from_object, is_1d_only_ea_dtype, - is_1d_only_ea_obj, is_bool_dtype, is_dataclass, is_datetime64_any_dtype, @@ -913,7 +912,7 @@ def _values( # type: ignore[override] mgr = self._mgr if isinstance(mgr, ArrayManager): - if len(mgr.arrays) == 1 and not is_1d_only_ea_obj(mgr.arrays[0]): + if len(mgr.arrays) == 1 and not is_1d_only_ea_dtype(mgr.arrays[0].dtype): # error: Item "ExtensionArray" of "Union[ndarray, ExtensionArray]" # has no attribute "reshape" return mgr.arrays[0].reshape(-1, 1) # type: ignore[union-attr] @@ -10050,7 +10049,7 @@ def func(values: np.ndarray): def blk_func(values, axis=1): if isinstance(values, ExtensionArray): - if not is_1d_only_ea_obj(values) and not isinstance( + if not is_1d_only_ea_dtype(values.dtype) and not isinstance( self._mgr, ArrayManager ): return values._reduce(name, axis=1, skipna=skipna, **kwds) diff --git a/pandas/core/groupby/ops.py b/pandas/core/groupby/ops.py index 467da586f604d..d4aa6ae9f4059 100644 --- a/pandas/core/groupby/ops.py +++ b/pandas/core/groupby/ops.py @@ -45,7 +45,7 @@ ensure_float64, ensure_int64, ensure_platform_int, - is_1d_only_ea_obj, + is_1d_only_ea_dtype, is_bool_dtype, is_categorical_dtype, is_complex_dtype, @@ -601,7 +601,7 @@ def cython_operation( raise NotImplementedError("number of dimensions is currently limited to 2") elif values.ndim == 2: assert axis == 1, axis - elif not is_1d_only_ea_obj(values): + elif not is_1d_only_ea_dtype(values.dtype): # Note: it is *not* the case that axis is always 0 for 1-dim values, # as we can have 1D ExtensionArrays that we need to treat as 2D assert axis == 0 diff --git a/pandas/core/internals/concat.py b/pandas/core/internals/concat.py index 50b12f5365964..991e4bbf4fbdb 100644 --- a/pandas/core/internals/concat.py +++ b/pandas/core/internals/concat.py @@ -27,7 +27,6 @@ ) from pandas.core.dtypes.common import ( is_1d_only_ea_dtype, - is_1d_only_ea_obj, is_datetime64tz_dtype, is_dtype_equal, ) @@ -478,7 +477,7 @@ def _concatenate_join_units(join_units: list[JoinUnit], copy: bool) -> ArrayLike else: concat_values = concat_values.copy() - elif any(is_1d_only_ea_obj(t) for t in to_concat): + elif any(is_1d_only_ea_dtype(t.dtype) for t in to_concat): # TODO(EA2D): special case not needed if all EAs used HybridBlocks # NB: we are still assuming here that Hybrid blocks have shape (1, N) # concatting with at least one EA means we are concatting a single column @@ -487,7 +486,9 @@ def _concatenate_join_units(join_units: list[JoinUnit], copy: bool) -> ArrayLike # error: No overload variant of "__getitem__" of "ExtensionArray" matches # argument type "Tuple[int, slice]" to_concat = [ - t if is_1d_only_ea_obj(t) else t[0, :] # type: ignore[call-overload] + t + if is_1d_only_ea_dtype(t.dtype) + else t[0, :] # type: ignore[call-overload] for t in to_concat ] concat_values = concat_compat(to_concat, axis=0, ea_compat_axis=True)