You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.21.0.txt
+47
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ Highlights include:
12
12
- Integration with `Apache Parquet <https://parquet.apache.org/>`__, including a new top-level :func:`read_parquet` and :func:`DataFrame.to_parquet` method, see :ref:`here <io.parquet>`.
13
13
- New user-facing :class:`pandas.api.types.CategoricalDtype` for specifying
14
14
categoricals independent of the data, see :ref:`here <whatsnew_0210.enhancements.categorical_dtype>`.
15
+
- The behavior of ``sum`` and ``prod`` on all-NaN Series/DataFrames is now consistent and no longer depends on whether `bottleneck <http://berkeleyanalytics.com/bottleneck>`__ is installed, see :ref:`here <whatsnew_0210.api_breaking.bottleneck>`
15
16
16
17
Check the :ref:`API Changes <whatsnew_0210.api_breaking>` and :ref:`deprecations <whatsnew_0210.deprecations>` before updating.
17
18
@@ -412,6 +413,52 @@ Current Behavior
412
413
413
414
s.loc[pd.Index([True, False, True])]
414
415
416
+
.. _whatsnew_0210.api_breaking.bottleneck:
417
+
418
+
Sum/Prod of all-NaN Series/DataFrames is now consistently NaN
The behavior of ``sum`` and ``prod`` on all-NaN Series/DataFrames is now consistent and no longer depends on
422
+
whether `bottleneck <http://berkeleyanalytics.com/bottleneck>`__ is installed. (:issue:`9422`, :issue:`15507`).
423
+
424
+
With ``sum`` or ``prod`` on an empty or all-``NaN`` ``Series``, or columns of a ``DataFrame``, the result will be all-``NaN``. See the :ref:`docs <missing_data.numeric_sum>`.
425
+
426
+
.. ipython:: python
427
+
428
+
s = Series([np.nan])
429
+
430
+
Previously NO ``bottleneck``
431
+
432
+
.. code_block:: ipython
433
+
434
+
In [2]: s.sum()
435
+
Out[2]: np.nan
436
+
437
+
Previously WITH ``bottleneck``
438
+
439
+
.. code_block:: ipython
440
+
441
+
In [2]: s.sum()
442
+
Out[2]: 0.0
443
+
444
+
New Behavior, without regards to the bottleneck installation.
445
+
446
+
.. ipython:: python
447
+
448
+
s.sum()
449
+
450
+
Note that this also changes the sum of an empty ``Series``
0 commit comments