I have a dataset
|category|
cat a
cat b
cat a
I'd like to be able to return something like (showing unique values and frequency)
category | freq |
cat a 2
cat b 1
I have a dataset
|category|
cat a
cat b
cat a
I'd like to be able to return something like (showing unique values and frequency)
category | freq |
cat a 2
cat b 1
This short little line of code will give you the output you want.
value_counts - Returns object containing counts of unique values
apply - count frequency in every column. If you set axis=1, you get frequncy in every row
fillna(0) - make output more fancy. Changed NaN to 0