Skip to content

Commit 80b4a9b

Browse files
Merge pull request #419 from felunka/bugfix/fix_pandas_deprecation
Fix is_categorical_dtype deprecation
2 parents 71537c1 + 58229b5 commit 80b4a9b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

category_encoders/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pandas as pd
77
import numpy as np
88
import sklearn.base
9+
from pandas.core.dtypes.dtypes import CategoricalDtype
910
from sklearn.base import BaseEstimator, TransformerMixin
1011
from sklearn.exceptions import NotFittedError
1112
from typing import Dict, List, Optional, Union
@@ -25,7 +26,7 @@ def convert_cols_to_list(cols):
2526
return list(cols)
2627
elif isinstance(cols, tuple):
2728
return list(cols)
28-
elif pd.api.types.is_categorical_dtype(cols):
29+
elif isinstance(cols, CategoricalDtype):
2930
return cols.astype(object).tolist()
3031

3132
return cols
@@ -47,7 +48,7 @@ def get_obj_cols(df):
4748

4849

4950
def is_category(dtype):
50-
return pd.api.types.is_categorical_dtype(dtype)
51+
return isinstance(dtype, CategoricalDtype)
5152

5253

5354
def convert_inputs(X, y, columns=None, index=None, deep=False):

0 commit comments

Comments
 (0)