Python Forum

Full Version: Extract the categorial variables of a DataFrame
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I am quite a begginer using Python , and I am struggling to extract the categorical variables (the columns) of my df that contain 6 or less unique values. I have many columns so I search a way to avoid doing it column by columns...

Thank you so much !

Tut
If you want to find all unique values for entire data frame, you can use pd.unique, e.g.
pd.unique(df.values.ravel())
df is your data frame.