@@ -14,6 +14,7 @@ users upgrade to this version.
1414Highlights include:
1515
1616- Release the Global Interpreter Lock (GIL) on some cython operations, see :ref:`here <whatsnew_0170.gil>`
17+ - The sorting API has been revamped to remove some long-time inconsistencies, see :ref:`here <whatsnew_0170.api_breaking.sorting>`
1718- The default for ``to_datetime`` will now be to ``raise`` when presented with unparseable formats,
1819 previously this would return the original input, see :ref:`here <whatsnew_0170.api_breaking.to_datetime>`
1920- The default for ``dropna`` in ``HDFStore`` has changed to ``False``, to store by default all rows even
@@ -207,6 +208,65 @@ Other enhancements
207208Backwards incompatible API changes
208209~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
209210
211+ .. _whatsnew_0170.api_breaking.sorting:
212+
213+ Changes to sorting API
214+ ^^^^^^^^^^^^^^^^^^^^^^
215+
216+ The sorting API has had some longtime inconsistencies. (:issue:`9816`,:issue:`8239`).
217+
218+ Here is a summary of the **prior** to 0.17.0 API
219+
220+ - ``Series.sort`` is **INPLACE** while ``DataFrame.sort`` returns a new object.
221+ - ``Series.order`` returned a new object
222+ - It was possible to use ``Series/DataFrame.sort_index`` to sort by **values** by passing the ``by`` keyword.
223+ - ``Series/DataFrame.sortlevel`` worked only on a ``MultiIndex`` for sorting by index.
224+
225+ To address these issues, we have revamped the API:
226+
227+ - We have introduced a new method, :meth:`DataFrame.sort_values`, which is the merger of ``DataFrame.sort()``, ``Series.sort()``,
228+ and ``Series.order``, to handle sorting of **values**.
229+ - The existing method ``Series.sort()`` has been deprecated and will be removed in a
230+ future version of pandas.
231+ - The ``by`` argument of ``DataFrame.sort_index()`` has been deprecated and will be removed in a future version of pandas.
232+ - The methods ``DataFrame.sort()``, ``Series.order()``, will not be recommended to use and will carry a deprecation warning
233+ in the doc-string.
234+ - The existing method ``.sort_index()`` will gain the ``level`` keyword to enable level sorting.
235+
236+ We now have two distinct and non-overlapping methods of sorting. A ``*`` marks items that
237+ will show a ``FutureWarning``.
238+
239+ To sort by the **values**:
240+
241+ ================================= ====================================
242+ Previous Replacement
243+ ================================= ====================================
244+ \*``Series.order()`` ``Series.sort_values()``
245+ \*``Series.sort()`` ``Series.sort_values(inplace=True)``
246+ \*``DataFrame.sort(columns=...)`` ``DataFrame.sort_values(by=...)``
247+ ================================= ====================================
248+
249+ To sort by the **index**:
250+
251+ ================================= ====================================
252+ Previous Equivalent
253+ ================================= ====================================
254+ ``Series.sort_index()`` ``Series.sort_index()``
255+ ``Series.sortlevel(level=...)`` ``Series.sort_index(level=...``)
256+ ``DataFrame.sort_index()`` ``DataFrame.sort_index()``
257+ ``DataFrame.sortlevel(level=...)`` ``DataFrame.sort_index(level=...)``
258+ \*``DataFrame.sort()`` ``DataFrame.sort_index()``
259+ ================================== ====================================
260+
261+ We have also deprecated and changed similar methods in two Series-like classes, ``Index`` and ``Categorical``.
262+
263+ ================================== ====================================
264+ Previous Replacement
265+ ================================== ====================================
266+ \*``Index.order()`` ``Index.sort_values()``
267+ \*``Categorical.order()`` ``Categorical.sort_values``
268+ ================================== ====================================
269+
210270.. _whatsnew_0170.api_breaking.to_datetime:
211271
212272Changes to to_datetime and to_timedelta
@@ -591,7 +651,7 @@ Removal of prior version deprecations/changes
591651^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
592652
593653- Remove use of some deprecated numpy comparison operations, mainly in tests. (:issue:`10569`)
594-
654+ - Removal of ``na_last`` parameters from ``Series.order()`` and ``Series.sort()``, in favor of ``na_position``, xref (:issue:`5231`)
595655
596656.. _whatsnew_0170.performance:
597657
0 commit comments