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`).
271
+
272
+
.. code-block:: ipython
273
+
274
+
In [6]: df = pd.DataFrame(["a", "b", "c"], dtype="category").iloc[0:2]
275
+
In [7]: df
276
+
Out[7]:
277
+
0
278
+
0 a
279
+
1 b
280
+
281
+
*Old Behavior*
282
+
283
+
.. code-block:: ipython
284
+
285
+
In [8]: df.groupby(level=0, observed=True).value_counts()
286
+
Out[8]:
287
+
0 a 1
288
+
1 b 1
289
+
dtype: int64
290
+
291
+
292
+
*New Behavior*
293
+
294
+
.. code-block:: ipython
295
+
296
+
In [9]: df.groupby(level=0, observed=True).value_counts()
0 commit comments