File tree 2 files changed +8
-40
lines changed
2 files changed +8
-40
lines changed Original file line number Diff line number Diff line change @@ -1231,44 +1231,6 @@ def needs_i8_conversion(arr_or_dtype) -> bool:
1231
1231
)
1232
1232
1233
1233
1234
- def np_issubclass_compat (unique_dtype , dtypes_set ) -> bool :
1235
- """
1236
- Check whether the provided dtype is a subclass of, or has an attribute
1237
- (e.g. _is_numeric) indiciating it is a subclass of any of the dtypes in
1238
- dtypes_set.
1239
-
1240
- Parameters
1241
- ----------
1242
- unique_dtype : dtype
1243
- The dtype to check.
1244
- dtypes_set : array-like
1245
- The dtypes to check unique_dtype is a sublass of.
1246
-
1247
- Returns
1248
- -------
1249
- boolean
1250
- Whether or not the unique_dtype is a subclass of dtype_set.
1251
-
1252
- Examples
1253
- --------
1254
- >>> np_issubclass_compat(pd.Int16Dtype(), [np.bool_, np.float])
1255
- False
1256
- >>> np_issubclass_compat(pd.Int16Dtype(), [np.integer])
1257
- True
1258
- >>> np_issubclass_compat(pd.BooleanDtype(), [np.bool_])
1259
- True
1260
- >>> np_issubclass_compat(pd.Float64Dtype(), [np.float])
1261
- True
1262
- >>> np_issubclass_compat(pd.Float64Dtype(), [np.number])
1263
- True
1264
- """
1265
- return issubclass (unique_dtype .type , tuple (dtypes_set )) or (
1266
- np .number in dtypes_set
1267
- and hasattr (unique_dtype , "_is_numeric" ) # is an extensionarray
1268
- and unique_dtype ._is_numeric
1269
- )
1270
-
1271
-
1272
1234
def is_numeric_dtype (arr_or_dtype ) -> bool :
1273
1235
"""
1274
1236
Check whether the provided array or dtype is of a numeric dtype.
Original file line number Diff line number Diff line change 114
114
is_object_dtype ,
115
115
is_scalar ,
116
116
is_sequence ,
117
- np_issubclass_compat ,
118
117
pandas_dtype ,
119
118
)
120
119
from pandas .core .dtypes .missing import isna , notna
@@ -3713,7 +3712,14 @@ def extract_unique_dtypes_from_dtypes_set(
3713
3712
extracted_dtypes = [
3714
3713
unique_dtype
3715
3714
for unique_dtype in unique_dtypes
3716
- if np_issubclass_compat (unique_dtype , dtypes_set )
3715
+ if (
3716
+ issubclass (unique_dtype .type , tuple (dtypes_set ))
3717
+ or (
3718
+ np .number in dtypes_set
3719
+ and hasattr (unique_dtype , "_is_numeric" )
3720
+ and unique_dtype ._is_numeric
3721
+ )
3722
+ )
3717
3723
]
3718
3724
return extracted_dtypes
3719
3725
You can’t perform that action at this time.
0 commit comments