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 :: what is the weather today 
Python :: how to convert categorical data to numerical data in python 
Python :: Access the elements using the [] syntax nested dictionary 
Python :: doctest example in python 
Python :: views django 
Python :: Iterate through string in python using for loop and rang 
Python :: openpyxl get row from sheet 
Python :: python *args and **kwargs 
Python :: how to change order of attributes of an element using beautiful soup 
Python :: journalctl not showing all python prints 
Python :: df describe 
Python :: _getexif 
Python :: add colorbar matplotlib 
Python :: telegram.ext 
Python :: dont truncate dataframe jupyter pd display options 
Python :: how to close ursina screen 
Python :: get single batch from torch data loader 
Python :: pandas join two dataframes 
Python :: python bubble plot 
Python :: Change Separator Value When Printing 
Python :: python email subject decode 
Python :: sum the contents of a list python 
Python :: Python Global in Nested Functions 
Python :: extract column of n array 
Python :: Adding Route In Django 
Python :: python program to check whether a specified value is contained in a group of values 
Python :: pandas fillna with mode 
Python :: python defaultdict default value 
Python :: create a list of sequential numbers in python 
Python :: python zip file 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =