Python Forum
Extract the categorial variables of a DataFrame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extract the categorial variables of a DataFrame
#1
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
Reply
#2
If you want to find all unique values for entire data frame, you can use pd.unique, e.g.
1
pd.unique(df.values.ravel())
df is your data frame.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Iterate through dataframe to extract delta of a particular time period lynnette1983 1 2,262 Oct-22-2020, 12:19 AM
Last Post: scidam
  extract specific content in a pandas dataframe with a regex? steve1040 0 14,474 Oct-05-2017, 03:17 AM
Last Post: steve1040

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020