Skip to content

Commit 6e507a4

Browse files
committed
move is_categorical_dtype()
1 parent 1a9fa40 commit 6e507a4

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pandas/core/internals/blocks.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1010,11 +1010,7 @@ def coerce_to_target_dtype(self, other):
10101010
if is_dtype_equal(self.dtype, dtype):
10111011
return self
10121012

1013-
if (
1014-
is_extension_array_dtype(self.dtype)
1015-
and not is_categorical_dtype(self.dtype)
1016-
and not self.is_datetime
1017-
):
1013+
if is_extension_array_dtype(self.dtype) and not is_categorical_dtype(self.dtype):
10181014
dtype = self.dtype
10191015

10201016
elif self.is_bool or is_object_dtype(dtype) or is_bool_dtype(dtype):
@@ -1060,6 +1056,8 @@ def coerce_to_target_dtype(self, other):
10601056
raise AssertionError(
10611057
f"possible recursion in coerce_to_target_dtype: {self} {other}"
10621058
)
1059+
if is_categorical_dtype(dtype) or self.is_datetime:
1060+
return self.astype(object)
10631061

10641062
try:
10651063
return self.astype(dtype)

0 commit comments

Comments
 (0)