Closed msrasmussen closed 8 months ago
It's a bit odd, I can't find anything mentioning that in the change log of pandas. The fix looks like a no-op so it seems a bit fishy. Might be worth having a look at pandas bug tracker in case it's something that will just get fixed soon
AFAICT it is deliberate:
Deprecated including the groups in computations when using DataFrameGroupBy.apply() and DataFrameGroupBy.resample(); pass include_groups=False to exclude the groups (GH 7155)
If I understand the PR correctly, some users are fed up having to explicitly exclude the group column, so now it is excluded by default. The proposed fix is to either explicitly specify the columns (like df.columns), or use the new include_groups=True argument in GroupBy.apply(include_groups=True).
FIX
Pandas 2.2.0 GroupBy.apply() no longer includes the group column by default. It must be explicitly selected.