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)
You can also do this with pandas by broadcasting your columns as categories first, e.g. dtype="category"
e.g.
cats = ['client', 'hotel', 'currency', 'ota', 'user_country']
df[cats] = df[cats].astype('category')
and then calling describe
:
df[cats].describe()
This will give you a nice table of value counts and a bit more :):
client hotel currency ota user_country
count 852845 852845 852845 852845 852845
unique 2554 17477 132 14 219
top 2198 13202 USD Hades US
freq 102562 8847 516500 242734 340992