Skip to content

Commit 85e6864

Browse files
DOC: clarfiy sum of empty Series case + matplotlib registering in 0.21.0 whatsnew (pandas-dev#18204)
* DOC: clarfiy sum of empty Series case in 0.21.0 whatsnew * DOC: emphasize matplotlib changes
1 parent b36dab5 commit 85e6864

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

doc/source/release.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Highlights include:
5252
- Integration with `Apache Parquet <https://parquet.apache.org/>`__, including a new top-level :func:`read_parquet` function and :meth:`DataFrame.to_parquet` method, see :ref:`here <whatsnew_0210.enhancements.parquet>`.
5353
- New user-facing :class:`pandas.api.types.CategoricalDtype` for specifying
5454
categoricals independent of the data, see :ref:`here <whatsnew_0210.enhancements.categorical_dtype>`.
55-
- 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>`.
55+
- 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, and ``sum`` and ``prod`` on empty Series now return NaN instead of 0, see :ref:`here <whatsnew_0210.api_breaking.bottleneck>`.
5656
- Compatibility fixes for pypy, see :ref:`here <whatsnew_0210.pypy>`.
5757
- Additions to the ``drop``, ``reindex`` and ``rename`` API to make them more consistent, see :ref:`here <whatsnew_0210.enhancements.drop_api>`.
5858
- Addition of the new methods ``DataFrame.infer_objects`` (see :ref:`here <whatsnew_0210.enhancements.infer_objects>`) and ``GroupBy.pipe`` (see :ref:`here <whatsnew_0210.enhancements.GroupBy_pipe>`).

doc/source/whatsnew/v0.21.0.txt

+32-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Highlights include:
1212
- Integration with `Apache Parquet <https://parquet.apache.org/>`__, including a new top-level :func:`read_parquet` function and :meth:`DataFrame.to_parquet` method, see :ref:`here <whatsnew_0210.enhancements.parquet>`.
1313
- New user-facing :class:`pandas.api.types.CategoricalDtype` for specifying
1414
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+
- 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, and ``sum`` and ``prod`` on empty Series now return NaN instead of 0, see :ref:`here <whatsnew_0210.api_breaking.bottleneck>`.
1616
- Compatibility fixes for pypy, see :ref:`here <whatsnew_0210.pypy>`.
1717
- Additions to the ``drop``, ``reindex`` and ``rename`` API to make them more consistent, see :ref:`here <whatsnew_0210.enhancements.drop_api>`.
1818
- Addition of the new methods ``DataFrame.infer_objects`` (see :ref:`here <whatsnew_0210.enhancements.infer_objects>`) and ``GroupBy.pipe`` (see :ref:`here <whatsnew_0210.enhancements.GroupBy_pipe>`).
@@ -369,47 +369,47 @@ Additionally, support has been dropped for Python 3.4 (:issue:`15251`).
369369

370370
.. _whatsnew_0210.api_breaking.bottleneck:
371371

372-
Sum/Prod of all-NaN Series/DataFrames is now consistently NaN
373-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
372+
Sum/Prod of all-NaN or empty Series/DataFrames is now consistently NaN
373+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
374374

375375
The behavior of ``sum`` and ``prod`` on all-NaN Series/DataFrames no longer depends on
376-
whether `bottleneck <http://berkeleyanalytics.com/bottleneck>`__ is installed. (:issue:`9422`, :issue:`15507`).
376+
whether `bottleneck <http://berkeleyanalytics.com/bottleneck>`__ is installed, and return value of ``sum`` and ``prod`` on an empty Series has changed (:issue:`9422`, :issue:`15507`).
377377

378378
Calling ``sum`` or ``prod`` on an empty or all-``NaN`` ``Series``, or columns of a ``DataFrame``, will result in ``NaN``. See the :ref:`docs <missing_data.numeric_sum>`.
379379

380380
.. ipython:: python
381381

382382
s = Series([np.nan])
383383

384-
Previously NO ``bottleneck``
384+
Previously WITHOUT ``bottleneck`` installed:
385385

386386
.. code-block:: ipython
387387

388388
In [2]: s.sum()
389389
Out[2]: np.nan
390390

391-
Previously WITH ``bottleneck``
391+
Previously WITH ``bottleneck``:
392392

393393
.. code-block:: ipython
394394

395395
In [2]: s.sum()
396396
Out[2]: 0.0
397397

398-
New Behavior, without regard to the bottleneck installation.
398+
New Behavior, without regard to the bottleneck installation:
399399

400400
.. ipython:: python
401401

402402
s.sum()
403403

404-
Note that this also changes the sum of an empty ``Series``
405-
406-
Previously regardless of ``bottlenck``
404+
Note that this also changes the sum of an empty ``Series``. Previously this always returned 0 regardless of a ``bottlenck`` installation:
407405

408406
.. code-block:: ipython
409407

410408
In [1]: pd.Series([]).sum()
411409
Out[1]: 0
412410

411+
but for consistency with the all-NaN case, this was changed to return NaN as well:
412+
413413
.. ipython:: python
414414

415415
pd.Series([]).sum()
@@ -877,6 +877,28 @@ New Behavior:
877877

878878
pd.interval_range(start=0, end=4)
879879

880+
.. _whatsnew_0210.api.mpl_converters:
881+
882+
No Automatic Matplotlib Converters
883+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
884+
885+
Pandas no longer registers our ``date``, ``time``, ``datetime``,
886+
``datetime64``, and ``Period`` converters with matplotlib when pandas is
887+
imported. Matplotlib plot methods (``plt.plot``, ``ax.plot``, ...), will not
888+
nicely format the x-axis for ``DatetimeIndex`` or ``PeriodIndex`` values. You
889+
must explicitly register these methods:
890+
891+
.. ipython:: python
892+
893+
from pandas.tseries import converter
894+
converter.register()
895+
896+
fig, ax = plt.subplots()
897+
plt.plot(pd.date_range('2017', periods=6), range(6))
898+
899+
Pandas built-in ``Series.plot`` and ``DataFrame.plot`` *will* register these
900+
converters on first-use (:issue:17710).
901+
880902
.. _whatsnew_0210.api:
881903

882904
Other API Changes
@@ -900,8 +922,6 @@ Other API Changes
900922
- Renamed non-functional ``index`` to ``index_col`` in :func:`read_stata` to improve API consistency (:issue:`16342`)
901923
- Bug in :func:`DataFrame.drop` caused boolean labels ``False`` and ``True`` to be treated as labels 0 and 1 respectively when dropping indices from a numeric index. This will now raise a ValueError (:issue:`16877`)
902924
- Restricted DateOffset keyword arguments. Previously, ``DateOffset`` subclasses allowed arbitrary keyword arguments which could lead to unexpected behavior. Now, only valid arguments will be accepted. (:issue:`17176`).
903-
- Pandas no longer registers matplotlib converters on import. The converters
904-
will be registered and used when the first plot is draw (:issue:`17710`)
905925

906926
.. _whatsnew_0210.deprecations:
907927

0 commit comments

Comments
 (0)