File tree 2 files changed +12
-8
lines changed
2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -564,8 +564,7 @@ def is_excluded_dtype(dtype) -> bool:
564
564
"""
565
565
These have kind = "O" but aren't string dtypes so need to be explicitly excluded
566
566
"""
567
- is_excluded_checks = (is_period_dtype , is_interval_dtype , is_categorical_dtype )
568
- return any (is_excluded (dtype ) for is_excluded in is_excluded_checks )
567
+ return isinstance (dtype , (PeriodDtype , IntervalDtype , CategoricalDtype ))
569
568
570
569
return _is_dtype (arr_or_dtype , condition )
571
570
@@ -1177,11 +1176,14 @@ def needs_i8_conversion(arr_or_dtype) -> bool:
1177
1176
# fastpath
1178
1177
dtype = arr_or_dtype
1179
1178
return dtype .kind in ["m" , "M" ] or dtype .type is Period
1180
- return (
1181
- is_datetime_or_timedelta_dtype (arr_or_dtype )
1182
- or is_datetime64tz_dtype (arr_or_dtype )
1183
- or is_period_dtype (arr_or_dtype )
1184
- )
1179
+
1180
+ try :
1181
+ dtype = get_dtype (arr_or_dtype )
1182
+ except (TypeError , ValueError ):
1183
+ return False
1184
+ if isinstance (dtype , np .dtype ):
1185
+ return dtype .kind in ["m" , "M" ]
1186
+ return isinstance (dtype , (PeriodDtype , DatetimeTZDtype ))
1185
1187
1186
1188
1187
1189
def is_numeric_dtype (arr_or_dtype ) -> bool :
Original file line number Diff line number Diff line change @@ -439,7 +439,9 @@ def array_equivalent(
439
439
# Slow path when we allow comparing different dtypes.
440
440
# Object arrays can contain None, NaN and NaT.
441
441
# string dtypes must be come to this path for NumPy 1.7.1 compat
442
- if is_string_dtype (left .dtype ) or is_string_dtype (right .dtype ):
442
+ if left .dtype .kind in "OSU" or right .dtype .kind in "OSU" :
443
+ # Note: `in "OSU"` is non-trivially faster than `in ["O", "S", "U"]`
444
+ # or `in ("O", "S", "U")`
443
445
return _array_equivalent_object (left , right , strict_nan )
444
446
445
447
# NaNs can occur in float and complex arrays.
You can’t perform that action at this time.
0 commit comments