Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas count specific value in column

(df[education]=='9th').sum()
Comment

pandas count occurrences of certain value in row

print df
  col1 education
0    a       9th
1    b       9th
2    c       8th

print df.education == '9th'
0     True
1     True
2    False
Name: education, dtype: bool

print df[df.education == '9th']
  col1 education
0    a       9th
1    b       9th

print df[df.education == '9th'].shape[0]
2
print len(df[df['education'] == '9th'])
2
Comment

PREVIOUS NEXT
Code Example
Python :: python install required packages 
Python :: python combine side by side dataframes 
Python :: negative cv2 
Python :: pil get image size 
Python :: beautifulsoup find by class 
Python :: python how to access clipboard 
Python :: mongodb between two values 
Python :: pytorch tensor change dimension order 
Python :: python diamond print 
Python :: capture output of os.system in python 
Python :: python print only 2 decimals 
Python :: how to update python in linux 
Python :: how to apply labelencoder on multiple columns at once 
Python :: squared sum of all elements in list python 
Python :: python check my gpu 
Python :: tkinter minsize 
Python :: python matplotlib plot thickness 
Python :: pandas add character to string 
Python :: how to append to every second item in list python 
Python :: pandas drop rows with null in specific column 
Python :: how to update sklearn using conda 
Python :: making spark session 
Python :: python prompt for input 
Python :: installing django celery beat pip 
Python :: plt plot circle 
Python :: how to separate string in python by blank line 
Python :: pandas to_csv append 
Python :: python import text file 
Python :: python get last modification time of file 
Python :: beautiful soup 4 python 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =