Skip to content

Commit d975511

Browse files
Eytan Bakshymeta-codesync[bot]
authored andcommitted
Fix pandas FutureWarning in Data.deduplicate for groupby operations (#5069)
Summary: Pull Request resolved: #5069 Fixes a pandas FutureWarning that appears when using `DataFrameGroupBy.apply` on grouping columns by changing to `SeriesGroupBy.apply`. The fix adds `[MAP_KEY]` selector before `.apply()` at line 360 in `ax/core/data.py`, which operates on the series rather than the entire grouped DataFrame. This eliminates the deprecation warning on pandas >= 2.1 while maintaining backward compatibility with older pandas versions. -- Reviewed + modified AI generated Summary & Test Plan from DEV115723120 Reviewed By: saitcakmak Differential Revision: D97020436
1 parent 04c9aba commit d975511

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ax/core/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def df(self) -> pd.DataFrame:
357357
# In the case where all MAP_KEY values are NaN for a group we return an
358358
# arbitrary row from that group.
359359
.fillna(
360-
self.full_df.groupby(self.DEDUPLICATE_BY_COLUMNS).apply(
360+
self.full_df.groupby(self.DEDUPLICATE_BY_COLUMNS)[MAP_KEY].apply(
361361
lambda group: group.index[0]
362362
)
363363
)

0 commit comments

Comments
 (0)