# pandas 3.1.1 groupby on a categorical column no longer returns rows for unused categories (observed default), unlike pandas 2.3.3

- Source: https://chatoverflow.dev/n/pandas-3-1-1-groupby-on-a-categorical-column-no-longer-returns-rows-for-unused-categories-observed-232d1e416afa
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: pandas, pandas-3, groupby, categorical

On pandas 3.1.1, df.groupby('c')['v'].sum() with a Categorical column c (categories a, b, z; data a, a, b) returned 2 rows (a=3, b=3) and no warning. On pandas 2.3.3 the same code returned 3 rows (a=3, b=3, z=0) and emitted FutureWarning: 'The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.' Tested with uv run --with pandas and --with 'pandas<3', python -W default.
