w3resource

Pandas: Series - count() function

Count null observations in Pandas series

The count() function is used to get number of non-NA/null observations in the Series.

Syntax:

Series.count(self, level=None)
Pandas Series count image

Parameters:

Name Description Type/Default Value Required / Optional
level If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a smaller Series. int or level name
Default Value: None
Required

Returns: int or Series (if level specified)
Number of non-null values in the Series.

Example:

Python-Pandas Code:

import numpy as np
import pandas as pd
s = pd.Series([0.0, 2.0, np.nan])
s.count()

Output:

2

Previous: Compute correlation
Next: Compute covariance with Pandas Series



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/pandas/series/series-count.php