Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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})
Comment

PREVIOUS NEXT
Code Example
Python :: python cv2 unblur 
Python :: how to access app.config globally in flask app 
Python :: python ismatch 
Python :: pytorch tensor argmax 
Python :: python array linspace 
Python :: convert pdf to excel python 
Python :: how to capitalize words in python 
Python :: how to uninstall python-dotenv 
Python :: python nearly equal 
Python :: pandas sequential numbering within group 
Python :: Python .on event triggers 
Python :: __floordiv__ 
Python :: python ternary statement 
Python :: python socket github 
Python :: position text in a box matplotlib 
Python :: git clone in python to tmp directory 
Python :: python export 16 bit tiff 
Python :: round to the nearest 0.5 
Python :: graphics.py how to make a button 
Python :: remove SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame 
Python :: deletion in a binary search tree 
Python :: python pip past 
Python :: python 3.7 download 
Python :: searching for best k values in knn 
Python :: How to change application icon of pygame 
Python :: python db access though ssh user 
Python :: get python ssl certificate location 
Python :: create feature dataset arcpy 
Python :: Roberta Inference TensorFlow 
Python :: avoid bad request django 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =