0

Similar to pandas unique values multiple columns I want to count the number of unique values per column. However, as the dtypes differ I get the following error: enter image description here

The data frame looks like enter image description here A small[['TARGET', 'title']].apply(pd.Series.describe) gives me the result, but only for the category types and I am unsure how to filter the index for only the last row with the unique values per column

Community
  • 1
  • 1
Georg Heiler
  • 16,916
  • 36
  • 162
  • 292

1 Answers1

1

Use apply and np.unique to grab the unique values in each column and take its size:

small[['TARGET','title']].apply(lambda x: np.unique(x).size)

Thanks!

Abdou
  • 12,931
  • 4
  • 39
  • 42