Answers for "how to find number of categories in python"

0

how to find number of categories in python

from collections import Counter
df = pd.DataFrame({'a':['apple','apple','banana','peach', 'banana', 'apple']})

print Counter(df['a'])
>> Counter({'apple': 3, 'banana': 2, 'peach': 1})
Posted by: Guest on April-06-2021

Code answers related to "how to find number of categories in python"

Python Answers by Framework

Browse Popular Code Answers by Language