v0.22.0 (December 29, 2017)¶
This is a major release from 0.21.1 and includes a single, API-breaking change. We recommend that all users upgrade to this version after carefully reading the release note (singular!).
Backwards incompatible API changes¶
Pandas 0.22.0 changes the handling of empty and all-NA sums and products. The summary is that
- The sum of an empty or all-NA
Seriesis now0 - The product of an empty or all-NA
Seriesis now1 - We’ve added a
min_countparameter to.sum()and.prod()controlling the minimum number of valid values for the result to be valid. If fewer thanmin_countnon-NA values are present, the result is NA. The default is0. To returnNaN, the 0.21 behavior, usemin_count=1.
Some background: In pandas 0.21, we fixed a long-standing inconsistency
in the return value of all-NA series depending on whether or not bottleneck
was installed. See Sum/Prod of all-NaN or empty Series/DataFrames is now consistently NaN. At the same
time, we changed the sum and prod of an empty Series to also be NaN.
Based on feedback, we’ve partially reverted those changes.
Arithmetic operations¶
The default sum for empty or all-NA Series is now 0.
pandas 0.21.x
In [1]: pd.Series([]).sum()
Out[1]: nan
In [2]: pd.Series([np.nan]).sum()
Out[2]: nan
pandas 0.22.0
In [1]: pd.Series([]).sum()
Out[1]: 0.0
In [2]: pd.Series([np.nan]).sum()