pytorch_tabular icon indicating copy to clipboard operation
pytorch_tabular copied to clipboard

Value Error when categorical column is of dtype "Categorical"

Open manujosephv opened this issue 3 years ago • 6 comments

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

manujosephv avatar May 26 '22 01:05 manujosephv

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.

stale[bot] avatar Jan 17 '23 06:01 stale[bot]

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)

DominikFilipiak avatar Jan 30 '24 22:01 DominikFilipiak