The pandas size attribute counts every value in a Series or DataFrame, including NaN values. Unlike count, it does not ignore missing entries and is an attribute rather than a method. section 5.2
Count all values in a cleaning task
After loading a parking-violations DataFrame, use df.size when the question concerns the total number of stored values, including missing ones. For a Series, np.size(s) provides the same kind of total-value count. If the question is only how many rows exist, compare len(df.index), which is preferred here for speed. section 5.2
Keep these counting choices separate:
- Use size for all values, including NaN, across Series and DataFrame objects. section 5.2
- Use count when missing values should be excluded, while recognizing its performance drawback on large DataFrames. section 5.2
- Use len(df.index) when the goal is the total number of DataFrame rows. section 5.2
