Skip to content

Commit

Permalink
MAINT remove deprecated is_categorical_dtype (scikit-learn#26156)
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre committed Apr 13, 2023
1 parent f5fe9fa commit a790c09
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sklearn/datasets/_arff_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def strip_single_quotes(input_string):
categorical_columns = [
name
for name, dtype in frame.dtypes.items()
if pd.api.types.is_categorical_dtype(dtype)
if isinstance(dtype, pd.CategoricalDtype)
]
for col in categorical_columns:
frame[col] = frame[col].cat.rename_categories(strip_single_quotes)
Expand All @@ -442,7 +442,7 @@ def strip_single_quotes(input_string):
categories = {
name: dtype.categories.tolist()
for name, dtype in frame.dtypes.items()
if pd.api.types.is_categorical_dtype(dtype)
if isinstance(dtype, pd.CategoricalDtype)
}
return X, y, None, categories

Expand Down
2 changes: 1 addition & 1 deletion sklearn/datasets/tests/test_openml.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def convert_numerical_and_categorical_dtypes(series):
pandas_series = frame_pandas[series.name]
if pd.api.types.is_numeric_dtype(pandas_series):
return series.astype(pandas_series.dtype)
elif pd.api.types.is_categorical_dtype(pandas_series):
elif isinstance(pandas_series.dtype, pd.CategoricalDtype):
# Compare categorical features by converting categorical liac uses
# strings to denote the categories, we rename the categories to make
# them comparable to the pandas parser. Fixing this behavior in
Expand Down

0 comments on commit a790c09

Please sign in to comment.