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:
The data frame looks like
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
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!