Skip to content

Commit 083d643

Browse files
jbrockmendelmroeschke
authored andcommitted
Backport PR pandas-dev#48428: BUG/TST: fix a bunch of arraymanager+pyarrow tests
1 parent 2a51062 commit 083d643

File tree

2 files changed

+30
-334
lines changed

2 files changed

+30
-334
lines changed

pandas/core/internals/array_manager.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -297,19 +297,10 @@ def apply_with_block(self: T, f, align_keys=None, swap_axis=True, **kwargs) -> T
297297
if obj.ndim == 2:
298298
kwargs[k] = obj[[i]]
299299

300-
# error: Item "ExtensionArray" of "Union[Any, ExtensionArray]" has no
301-
# attribute "tz"
302-
if hasattr(arr, "tz") and arr.tz is None: # type: ignore[union-attr]
303-
# DatetimeArray needs to be converted to ndarray for DatetimeLikeBlock
304-
305-
# error: Item "ExtensionArray" of "Union[Any, ExtensionArray]" has no
306-
# attribute "_data"
307-
arr = arr._data # type: ignore[union-attr]
308-
elif arr.dtype.kind == "m" and not isinstance(arr, np.ndarray):
309-
# TimedeltaArray needs to be converted to ndarray for TimedeltaBlock
310-
311-
# error: "ExtensionArray" has no attribute "_data"
312-
arr = arr._data # type: ignore[attr-defined]
300+
if isinstance(arr.dtype, np.dtype) and not isinstance(arr, np.ndarray):
301+
# i.e. TimedeltaArray, DatetimeArray with tz=None. Need to
302+
# convert for the Block constructors.
303+
arr = np.asarray(arr)
313304

314305
if self.ndim == 2:
315306
arr = ensure_block_shape(arr, 2)

0 commit comments

Comments
 (0)