ARM-software / lisa

Linux Integrated System Analysis
Apache License 2.0
200 stars 119 forks source link

Fix a couple of GroupBy.apply() deprecations #2183

Closed msrasmussen closed 8 months ago

msrasmussen commented 8 months ago

FIX

Pandas 2.2.0 GroupBy.apply() no longer includes the group column by default. It must be explicitly selected.

douglas-raillard-arm commented 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

msrasmussen commented 8 months ago

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).