Skip to content

Commit

Permalink
Fix a couple of GroupBy.apply() deprecations
Browse files Browse the repository at this point in the history
FIX

Pandas 2.2.0 GroupBy.apply() no longer includes the group column by
default. It must be explicitly selected.
  • Loading branch information
msrasmussen authored and douglas-raillard-arm committed Jan 25, 2024
1 parent 78c7e98 commit cc06b51
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lisa/analysis/pixel6.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def make_chan_df(df):
df = pd.DataFrame(dict(power=power, channel=df['chan_name']))
return df.dropna()

df = grouped.apply(make_chan_df)
df = grouped[df.columns].apply(make_chan_df)
df['channel'] = df['channel'].astype('category').cat.rename_categories(Pixel6Analysis.EMETER_CHAN_NAMES)

return df
Expand Down
2 changes: 1 addition & 1 deletion lisa/datautils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ def df_combine_duplicates(df, func, output_col, cols=None, all_col=True, prune=T
# Apply the function to each group, and assign the result to the output
# Note that we cannot use GroupBy.transform() as it currently cannot handle
# NaN groups.
output = df.groupby('duplicate_group', sort=False, as_index=True, group_keys=False, observed=True).apply(func)
output = df.groupby('duplicate_group', sort=False, as_index=True, group_keys=False, observed=True)[df.columns].apply(func)
if not output.empty:
init_df[output_col].update(output)

Expand Down

0 comments on commit cc06b51

Please sign in to comment.