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)
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
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics