Python | Pandas dataframe.count()
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
dataframe.count() is used to count the no. of non-NA/null observations across the given axis. It works with non-floating type data as well.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Syntax: DataFrame.count(axis=0, level=None, numeric_only=False)
axis : 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise
level : If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a DataFrame
numeric_only : Include only float, int, boolean data
Returns: count : Series (or DataFrame if level specified)
Example #1: Use
count() function to find the number of non-NA/null value across the row axis.
Now find the count of non-NA value across the row axis
Example #2: Use
count() function to find the number of non-NA/null value across the column.