pandas.Series.count¶
Return number of non-NA/null observations in the Series.
- param level
- int or level name, default None
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a smaller Series.
- return
int or Series (if level specified) Number of non-null values in the Series.
Limitations¶
Parameter level
is currently unsupported.
Examples¶
import pandas as pd
import numpy as np
from numba import njit
@njit
def series_count():
s = pd.Series([1, 2, np.nan])
out_series = s.count()
return out_series # Expect the number of non-Nan values == '2'
print(series_count())
$ python ./series/series_count.py
2
See also
- Series.value_counts
Return a Series containing counts of unique values.
- Series.str.len
Count the length of each element in the Series.