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
Calling :meth:`.DataFrameGroupBy.value_counts` with ``observed=True`` would incorrectly drop non-observed categories of non-grouping columns (:issue:`46357`).
397
+
398
+
.. code-block:: ipython
399
+
400
+
In [6]: df = pd.DataFrame(["a", "b", "c"], dtype="category").iloc[0:2]
401
+
In [7]: df
402
+
Out[7]:
403
+
0
404
+
0 a
405
+
1 b
406
+
407
+
*Old Behavior*
408
+
409
+
.. code-block:: ipython
410
+
411
+
In [8]: df.groupby(level=0, observed=True).value_counts()
412
+
Out[8]:
413
+
0 a 1
414
+
1 b 1
415
+
dtype: int64
416
+
417
+
418
+
*New Behavior*
419
+
420
+
.. code-block:: ipython
421
+
422
+
In [9]: df.groupby(level=0, observed=True).value_counts()
0 commit comments