From 45ce6a9f6f42afd3eb2ccc3bf167594a9b557338 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 27 Jan 2021 19:31:09 -0800 Subject: [PATCH] REF: avoid using Block attributes --- pandas/core/internals/concat.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pandas/core/internals/concat.py b/pandas/core/internals/concat.py index 0b611bfdb1f10..9e4f535ebcbbe 100644 --- a/pandas/core/internals/concat.py +++ b/pandas/core/internals/concat.py @@ -264,7 +264,9 @@ def get_reindexed_values(self, empty_dtype: DtypeObj, upcasted_na) -> ArrayLike: fill_value = upcasted_na if self.is_na: - if getattr(self.block, "is_object", False): + blk_dtype = getattr(self.block, "dtype", None) + + if blk_dtype == np.dtype(object): # we want to avoid filling with np.nan if we are # using None; we already know that we are all # nulls @@ -272,17 +274,16 @@ def get_reindexed_values(self, empty_dtype: DtypeObj, upcasted_na) -> ArrayLike: if len(values) and values[0] is None: fill_value = None - if getattr(self.block, "is_datetimetz", False) or is_datetime64tz_dtype( + if is_datetime64tz_dtype(blk_dtype) or is_datetime64tz_dtype( empty_dtype ): if self.block is None: # TODO(EA2D): special case unneeded with 2D EAs - return DatetimeArray( - np.full(self.shape[1], fill_value.value), dtype=empty_dtype - ) - elif getattr(self.block, "is_categorical", False): + i8values = np.full(self.shape[1], fill_value.value) + return DatetimeArray(i8values, dtype=empty_dtype) + elif is_categorical_dtype(blk_dtype): pass - elif getattr(self.block, "is_extension", False): + elif is_extension_array_dtype(blk_dtype): pass elif is_extension_array_dtype(empty_dtype): missing_arr = empty_dtype.construct_array_type()._from_sequence(