@@ -14,6 +14,7 @@ users upgrade to this version.
14
14
Highlights include:
15
15
16
16
- 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>`
17
18
- The default for ``to_datetime`` will now be to ``raise`` when presented with unparseable formats,
18
19
previously this would return the original input, see :ref:`here <whatsnew_0170.api_breaking.to_datetime>`
19
20
- The default for ``dropna`` in ``HDFStore`` has changed to ``False``, to store by default all rows even
@@ -187,6 +188,65 @@ Other enhancements
187
188
Backwards incompatible API changes
188
189
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
189
190
191
+ .. _whatsnew_0170.api_breaking.sorting:
192
+
193
+ Changes to sorting API
194
+ ^^^^^^^^^^^^^^^^^^^^^^
195
+
196
+ The sorting API has had some longtime inconsistencies. (:issue:`9816`,:issue:`8239`).
197
+
198
+ Here is a summary of the **prior** to 0.17.0 API
199
+
200
+ - ``Series.sort`` is **INPLACE** while ``DataFrame.sort`` returns a new object.
201
+ - ``Series.order`` returned a new object
202
+ - It was possible to use ``Series/DataFrame.sort_index`` to sort by **values** by passing the ``by`` keyword.
203
+ - ``Series/DataFrame.sortlevel`` worked only on a ``MultiIndex`` for sorting by index.
204
+
205
+ To address these issues, we have revamped the API:
206
+
207
+ - We have introduced a new method, :meth:`DataFrame.sort_values`, which is the merger of ``DataFrame.sort()``, ``Series.sort()``,
208
+ and ``Series.order``, to handle sorting of **values**.
209
+ - The existing method ``Series.sort()`` has been deprecated and will be removed in a
210
+ future version of pandas.
211
+ - The ``by`` argument of ``DataFrame.sort_index()`` has been deprecated and will be removed in a future version of pandas.
212
+ - The methods ``DataFrame.sort()``, ``Series.order()``, will not be recommended to use and will carry a deprecation warning
213
+ in the doc-string.
214
+ - The existing method ``.sort_index()`` will gain the ``level`` keyword to enable level sorting.
215
+
216
+ We now have two distinct and non-overlapping methods of sorting. A ``*`` marks items that
217
+ will show a ``FutureWarning``.
218
+
219
+ To sort by the **values**:
220
+
221
+ ================================= ====================================
222
+ Previous Replacement
223
+ ================================= ====================================
224
+ \*``Series.order()`` ``Series.sort_values()``
225
+ \*``Series.sort()`` ``Series.sort_values(inplace=True)``
226
+ \*``DataFrame.sort(columns=...)`` ``DataFrame.sort_values(by=...)``
227
+ ================================= ====================================
228
+
229
+ To sort by the **index**:
230
+
231
+ ================================= ====================================
232
+ Previous Equivalent
233
+ ================================= ====================================
234
+ ``Series.sort_index()`` ``Series.sort_index()``
235
+ ``Series.sortlevel(level=...)`` ``Series.sort_index(level=...``)
236
+ ``DataFrame.sort_index()`` ``DataFrame.sort_index()``
237
+ ``DataFrame.sortlevel(level=...)`` ``DataFrame.sort_index(level=...)``
238
+ \*``DataFrame.sort()`` ``DataFrame.sort_index()``
239
+ ================================== ====================================
240
+
241
+ We have also deprecated and changed similar methods in two Series-like classes, ``Index`` and ``Categorical``.
242
+
243
+ ================================== ====================================
244
+ Previous Replacement
245
+ ================================== ====================================
246
+ \*``Index.order()`` ``Index.sort_values()``
247
+ \*``Categorical.order()`` ``Categorical.sort_values``
248
+ ================================== ====================================
249
+
190
250
.. _whatsnew_0170.api_breaking.to_datetime:
191
251
192
252
Changes to to_datetime and to_timedelta
@@ -570,7 +630,7 @@ Removal of prior version deprecations/changes
570
630
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
571
631
572
632
- Remove use of some deprecated numpy comparison operations, mainly in tests. (:issue:`10569`)
573
-
633
+ - Removal of ``na_last`` parameters from ``Series.order()`` and ``Series.sort()``, in favor of ``na_position``, xref (:issue:`5231`)
574
634
575
635
.. _whatsnew_0170.performance:
576
636
0 commit comments