how to find number of categories in python

Solutions on MaxInterview for how to find number of categories in python by the best coders in the world

showing results for - "how to find number of categories in python"
Caiden
30 Aug 2020
1from collections import Counter
2df = pd.DataFrame({'a':['apple','apple','banana','peach', 'banana', 'apple']})
3
4print Counter(df['a'])
5>> Counter({'apple': 3, 'banana': 2, 'peach': 1})
6
similar questions
queries leading to this page
how to find number of categories in python