8000 MAINT remove deprecated is_categorical_dtype (#26156) · Veghit/scikit-learn@de3824d · GitHub
[go: up one dir, main page]

Skip to content

Commit de3824d

Browse files
glemaitreItay
authored andcommitted
MAINT remove deprecated is_categorical_dtype (scikit-learn#26156)
1 parent a9d6baa commit de3824d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sklearn/datasets/_arff_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def strip_single_quotes(input_string):
427427
categorical_columns = [
428428
name
429429
for name, dtype in frame.dtypes.items()
430-
if pd.api.types.is_categorical_dtype(dtype)
430+
if isinstance(dtype, pd.CategoricalDtype)
431431
]
432432
for col in categorical_columns:
433433
frame[col] = frame[col].cat.rename_categories(strip_single_quotes)
@@ -442,7 +442,7 @@ def strip_single_quotes(input_string):
442442
categories = {
443443
name: dtype.categories.tolist()
444444
for name, dtype in frame.dtypes.items()
445-
if pd.api.types.is_categorical_dtype(dtype)
445+
if isinstance(dtype, pd.CategoricalDtype)
446446
}
447447
return X, y, None, categories
448448

sklearn/datasets/tests/test_openml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def convert_numerical_and_categorical_dtypes(series):
376376
pandas_series = frame_pandas[series.name]
377377
if pd.api.types.is_numeric_dtype(pandas_series):
378378
return series.astype(pandas_series.dtype)
379-
elif pd.api.types.is_categorical_dtype(pandas_series):
379+
elif isinstance(pandas_series.dtype, pd.CategoricalDtype):
380380
# Compare categorical features by converting categorical liac uses
381381
# strings to denote the categories, we rename the categories to make
382382
# them comparable to the pandas parser. Fixing this behavior in

0 commit comments

Comments
 (0)
0