Skip to content

Commit ebf6c8f

Browse files
authored
PERF: remove is_1d_only_ea_obj (#52605)
1 parent 5ab10a3 commit ebf6c8f

File tree

3 files changed

+3
-22
lines changed

3 files changed

+3
-22
lines changed

pandas/core/array_algos/take.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from pandas.core.dtypes.cast import maybe_promote
1818
from pandas.core.dtypes.common import (
1919
ensure_platform_int,
20-
is_1d_only_ea_obj,
20+
is_1d_only_ea_dtype,
2121
)
2222
from pandas.core.dtypes.missing import na_value_for_dtype
2323

@@ -105,7 +105,7 @@ def take_nd(
105105
if not isinstance(arr, np.ndarray):
106106
# i.e. ExtensionArray,
107107
# includes for EA to catch DatetimeArray, TimedeltaArray
108-
if not is_1d_only_ea_obj(arr):
108+
if not is_1d_only_ea_dtype(arr.dtype):
109109
# i.e. DatetimeArray, TimedeltaArray
110110
arr = cast("NDArrayBackedExtensionArray", arr)
111111
return arr.take(

pandas/core/dtypes/common.py

-18
Original file line numberDiff line numberDiff line change
@@ -1243,23 +1243,6 @@ def is_bool_dtype(arr_or_dtype) -> bool:
12431243
return issubclass(dtype.type, np.bool_)
12441244

12451245

1246-
def is_1d_only_ea_obj(obj: Any) -> bool:
1247-
"""
1248-
ExtensionArray that does not support 2D, or more specifically that does
1249-
not use HybridBlock.
1250-
"""
1251-
from pandas.core.arrays import (
1252-
DatetimeArray,
1253-
ExtensionArray,
1254-
PeriodArray,
1255-
TimedeltaArray,
1256-
)
1257-
1258-
return isinstance(obj, ExtensionArray) and not isinstance(
1259-
obj, (DatetimeArray, TimedeltaArray, PeriodArray)
1260-
)
1261-
1262-
12631246
def is_1d_only_ea_dtype(dtype: DtypeObj | None) -> bool:
12641247
"""
12651248
Analogue to is_extension_array_dtype but excluding DatetimeTZDtype.
@@ -1676,7 +1659,6 @@ def is_all_strings(value: ArrayLike) -> bool:
16761659
"infer_dtype_from_object",
16771660
"INT64_DTYPE",
16781661
"is_1d_only_ea_dtype",
1679-
"is_1d_only_ea_obj",
16801662
"is_all_strings",
16811663
"is_any_real_numeric_dtype",
16821664
"is_array_like",

pandas/core/internals/blocks.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
from pandas.core.dtypes.common import (
5757
ensure_platform_int,
5858
is_1d_only_ea_dtype,
59-
is_1d_only_ea_obj,
6059
is_dtype_equal,
6160
is_list_like,
6261
is_string_dtype,
@@ -356,7 +355,7 @@ def _split_op_result(self, result: ArrayLike) -> list[Block]:
356355
# if we get a 2D ExtensionArray, we need to split it into 1D pieces
357356
nbs = []
358357
for i, loc in enumerate(self._mgr_locs):
359-
if not is_1d_only_ea_obj(result):
358+
if not is_1d_only_ea_dtype(result.dtype):
360359
vals = result[i : i + 1]
361360
else:
362361
vals = result[i]

0 commit comments

Comments
 (0)