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
In previous versions of pandas, :meth:`DataFrame.value_counts` with ``sort=False`` would sort the result by row labels (as was documented). This was nonintuitive and inconsistent with :meth:`Series.value_counts` which would maintain the order of the input. Now :meth:`DataFrame.value_counts` will maintain the order of the input.
212
+
213
+
.. ipython:: python
214
+
215
+
df = pd.DataFrame(
216
+
{
217
+
"a": [2, 2, 2, 2, 1, 1, 1, 1],
218
+
"b": [2, 1, 3, 1, 2, 3, 1, 1],
219
+
}
220
+
)
221
+
df
222
+
223
+
*Old behavior*
224
+
225
+
.. code-block:: ipython
226
+
227
+
In [3]: df.value_counts(sort=False)
228
+
Out[3]:
229
+
a b
230
+
1 1 2
231
+
2 1
232
+
3 1
233
+
2 1 2
234
+
2 1
235
+
3 1
236
+
Name: count, dtype: int64
237
+
238
+
*New behavior*
239
+
240
+
.. ipython:: python
241
+
242
+
df.value_counts(sort=False)
243
+
244
+
This change also applies to :meth:`.DataFrameGroupBy.value_counts`. Here, there are two options for sorting: one ``sort`` passed to :meth:`DataFrame.groupby` and one passed directly to :meth:`.DataFrameGroupBy.value_counts`. The former will determine whether to sort the groups, the latter whether to sort the counts. All non-grouping columns will maintain the order of the input *within groups*.
245
+
246
+
*Old behavior*
247
+
248
+
.. code-block:: ipython
249
+
250
+
In [5]: df.groupby("a", sort=True).value_counts(sort=False)
- Bug in :func:`eval` on :class:`ExtensionArray` on including division ``/`` failed with a ``TypeError``. (:issue:`58748`)
702
763
- Bug in :func:`eval` where the names of the :class:`Series` were not preserved when using ``engine="numexpr"``. (:issue:`10239`)
703
764
- Bug in :func:`eval` with ``engine="numexpr"`` returning unexpected result for float division. (:issue:`59736`)
765
+
- Bug in :func:`to_numeric` raising ``TypeError`` when ``arg`` is a :class:`Timedelta` or :class:`Timestamp` scalar. (:issue:`59944`)
704
766
- Bug in :func:`unique` on :class:`Index` not always returning :class:`Index` (:issue:`57043`)
705
767
- Bug in :meth:`DataFrame.apply` where passing ``engine="numba"`` ignored ``args`` passed to the applied function (:issue:`58712`)
706
768
- Bug in :meth:`DataFrame.eval` and :meth:`DataFrame.query` which caused an exception when using NumPy attributes via ``@`` notation, e.g., ``df.eval("@np.floor(a)")``. (:issue:`58041`)
0 commit comments