Sum across all NaNs in pandas returns zero?

pandas documentation » API Reference » DataFrame » pandas.DataFrame »

DataFrame.sum(self, axis=None, skipna=None, level=None, numeric_only=None, min_count=0, **kwargs)

min_count: int, default 0

The required number of valid values to
perform the operation. If fewer than min_count non-NA values are
present the result will be NA.

New in version 0.22.0: Added with the default being 0. This means the
sum of an all-NA or empty Series is 0, and the product of an all-NA or
empty Series is 1.

Quoting from pandas latest docs it says the min_count will be 0 for the all-NA series.

If you say min_count=1 then the result of the sum will be a NaN.

Leave a Comment