Fix group-key columns in SeriesGroupBy list-agg and any/all with as_index=False - #22813
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
SeriesGroupBy list-agg and any/all with as_index=False
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughPrevents boolean coercion of grouping-key columns in DataFrame aggregation results and corrects MultiIndex-to-Index flattening for SeriesGroupBy. Updates pandas-testing expected-failure mappings to reflect the behavioral changes. ChangesGroupBy Aggregation Fixes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/merge |
Description
Fixes two bugs in
SeriesGroupByaggregations withas_index=False, where the group-key columns are materialized as output columns. Both only surfaced with categorical group keys, which is why they showed up in thecudf.pandastests/groupby/test_categorical.py::test_agg_listcases.SeriesGroupBy.agg([func])blanked the key-column name. A list aggregation produces a columnMultiIndex; withas_index=Falsethe key is inserted as a(key, "")tuple byreset_index. The result columns were collapsed with a blanketdroplevel(0), which keeps the empty padding level and so renamed the key column to""(e.g.["a1", "var"]became["", "var"]). It now keeps the key name for key columns and the aggregation name for value columns.any/allcorrupted the categorical key column._bool_reduceimplementsany/allasmax/minon bool-coerced columns, then casts the results back tobool. Withas_index=Falsethat loop also ran over the key columns inserted into the result, turning e.g. a categorical key[0, 1]into[False, True]. It now skips the group-key columns when coercing tobool.This un-
xfails the previously-failingtests/groupby/test_categorical.py::test_agg_list[...]cases in thecudf.pandaspandas test suite (and incidentally fixestest_category_order_reducer). cuDF's own groupby test-suite shows no regressions.Checklist