Skip to content

Latest commit

 

History

History
122 lines (92 loc) · 6.07 KB

v1.5.1.rst

File metadata and controls

122 lines (92 loc) · 6.07 KB

What's new in 1.5.1 (October ??, 2022)

These are the changes in pandas 1.5.1. See :ref:`release` for a full changelog including other versions of pandas.

{{ header }}

Behavior of groupby with categorical groupers (:issue:`48645`)

In versions of pandas prior to 1.5, groupby with dropna=False would still drop NA values when the grouper was a categorical dtype. A fix for this was attempted in 1.5, however it introduced a regression where passing observed=False and dropna=False to groupby would result in only observed categories. It was found that the patch fixing the dropna=False bug is incompatible with observed=False, and decided that the best resolution is to restore the correct observed=False behavior at the cost of reintroducing the dropna=False bug.

.. ipython:: python

   df = pd.DataFrame(
       {
           "x": pd.Categorical([1, None], categories=[1, 2, 3]),
           "y": [3, 4],
       }
   )
   df

1.5.0 behavior:

In [3]: # Correct behavior, NA values are not dropped
        df.groupby("x", observed=True, dropna=False).sum()
Out[3]:
     y
x
1    3
NaN  4


In [4]: # Incorrect behavior, only observed categories present
        df.groupby("x", observed=False, dropna=False).sum()
Out[4]:
     y
x
1    3
NaN  4

1.5.1 behavior:

.. ipython:: python

   # Incorrect behavior, NA values are dropped
   df.groupby("x", observed=True, dropna=False).sum()

   # Correct behavior, unobserved categories present (NA values still dropped)
   df.groupby("x", observed=False, dropna=False).sum()

Fixed regressions

Bug fixes

Other

  • Avoid showing deprecated signatures when introspecting functions with warnings about arguments becoming keyword-only (:issue:`48692`)

Contributors