`count` measures populated data: it returns the number of non-NaN values. On a Series, the result is one integer; on a DataFrame, it is a Series whose index is the original column names and whose values are each column’s non-missing counts. That makes it useful both for checking completeness and for answering “how many matching records?” after selecting rows. section 3.2 section 8.2
Count selected taxi rides
Build a boolean condition, use `loc` to select matching rows and one relevant column, then call `count()`. For example, selecting `passenger_count > 8` and counting `passenger_count` reports nine January 2019 rides. The selected column matters: `count()` excludes missing values, so it is most reliable as a row count when that column is populated for the records of interest. section 3.2
df = DataFrame([[10, 20, np.NaN, 40],
[50, np.NaN, np.NaN, np.NaN],
[np.NaN, 60, 70, 80]],
index=list('abc'),
columns=list('wxyz'))
df.count()
Run this small DataFrame example to see columnwise results: missing entries reduce each column’s count independently, producing a Series rather than one DataFrame-wide total. section 3.2
Use `count` in progressively broader analytical patterns:
- Compare periods by filtering each year, counting a selected column, and subtracting the results. section 3.6
- Measure response totals across many survey columns, then sort the count Series to identify the most common reported languages. section 8.2
- Count records within groups by grouping on one or more keys, counting a nongrouping identifier, then sorting or taking the largest result. section 13.3
- Choose `len(df.index)` or `size` when the goal is every row or value including NaN; `count` intentionally answers a different question. section 5.2
`count` also supports descriptive statistics: `describe()` includes the non-NaN count alongside mean, standard deviation, quantiles, and extrema. In calculations such as a mean or population standard deviation, the same count supplies the denominator for the available values. section 1.15 section 1.5




