File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -57,13 +57,11 @@ def _align_df_categories(
57
57
continue
58
58
59
59
if cat_missing_method == "convert" and not has_missing_category [column ]:
60
- unseen_categories = set (df [column ].unique ()) - set (
61
- dtypes [column ].categories
62
- )
60
+ unseen_categories = set (df [column ].unique ())
61
+ unseen_categories = unseen_categories - set (dtypes [column ].categories )
63
62
else :
64
- unseen_categories = set (df [column ].dropna ().unique ()) - set (
65
- dtypes [column ].categories
66
- )
63
+ unseen_categories = set (df [column ].dropna ().unique ())
64
+ unseen_categories = unseen_categories - set (dtypes [column ].categories )
67
65
68
66
if unseen_categories :
69
67
raise ValueError (
@@ -91,7 +89,7 @@ def _add_missing_categories(
91
89
categorical_dtypes = [
92
90
column
93
91
for column , dtype in dtypes .items ()
94
- if pd . api . types . is_categorical_dtype (dtype ) and (column in df )
92
+ if isinstance (dtype , pd . CategoricalDtype ) and (column in df )
95
93
]
96
94
97
95
for column in categorical_dtypes :
You can’t perform that action at this time.
0 commit comments