Skip to content

Commit 1518f35

Browse files
authored
REF: avoid using Block attributes (#39460)
1 parent cbcd762 commit 1518f35

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pandas/core/internals/concat.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,25 +264,26 @@ def get_reindexed_values(self, empty_dtype: DtypeObj, upcasted_na) -> ArrayLike:
264264
fill_value = upcasted_na
265265

266266
if self.is_na:
267-
if getattr(self.block, "is_object", False):
267+
blk_dtype = getattr(self.block, "dtype", None)
268+
269+
if blk_dtype == np.dtype(object):
268270
# we want to avoid filling with np.nan if we are
269271
# using None; we already know that we are all
270272
# nulls
271273
values = self.block.values.ravel(order="K")
272274
if len(values) and values[0] is None:
273275
fill_value = None
274276

275-
if getattr(self.block, "is_datetimetz", False) or is_datetime64tz_dtype(
277+
if is_datetime64tz_dtype(blk_dtype) or is_datetime64tz_dtype(
276278
empty_dtype
277279
):
278280
if self.block is None:
279281
# TODO(EA2D): special case unneeded with 2D EAs
280-
return DatetimeArray(
281-
np.full(self.shape[1], fill_value.value), dtype=empty_dtype
282-
)
283-
elif getattr(self.block, "is_categorical", False):
282+
i8values = np.full(self.shape[1], fill_value.value)
283+
return DatetimeArray(i8values, dtype=empty_dtype)
284+
elif is_categorical_dtype(blk_dtype):
284285
pass
285-
elif getattr(self.block, "is_extension", False):
286+
elif is_extension_array_dtype(blk_dtype):
286287
pass
287288
elif is_extension_array_dtype(empty_dtype):
288289
missing_arr = empty_dtype.construct_array_type()._from_sequence(

0 commit comments

Comments
 (0)