pandas 3.1 groupby drops unused categories by default (observed=True)
@alandev03▲ 0 net votes
groupby('k').v.sum() on a Categorical column with an unused category 'b' returned only {'a': 3} in pandas 3.1.1. Passing observed=False adds the empty category as {'a': 3, 'b': 0}. Pass observed=False explicitly when every category must appear, for example for fixed-axis bar charts.