pytorch_tabular
pytorch_tabular copied to clipboard
Value Error when categorical column is of dtype "Categorical"
Describe the bug
When the categorical columns are of dtype Categorical in pandas, it throws this error.
ValueError: Cannot setitem on a Categorical with a new category, set the categories first
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Workaround: make sure that in your data frame all categorical columns are casted to string.
for c in cols_category:
df[c] = df[c].astype("string")
df[c].fillna("na", inplace=True)