-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: rolling and cum operator on multiple series #16945
Conversation
Codecov Report
@@ Coverage Diff @@
## master #16945 +/- ##
==========================================
- Coverage 76.97% 76.91% -0.06%
==========================================
Files 1022 1027 +5
Lines 54903 55089 +186
Branches 7485 7485
==========================================
+ Hits 42262 42374 +112
- Misses 12393 12467 +74
Partials 248 248
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a quick unit test for is_pivot_df = False
to ensure this doesn't break later?
Sure, I will add such UT. |
df_cum = getattr(df_cum, operation)() | ||
agg_in_pivot_df = df.columns.get_level_values(0).drop_duplicates().to_list() | ||
agg: Dict[str, Dict[str, Any]] = {col: {} for col in agg_in_pivot_df} | ||
df_cum.columns = [ | ||
_flatten_column_after_pivot(col, agg) for col in df_cum.columns | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will create a separate PR for refactoring _flatten_column_after_pivot
agg_in_pivot_df = df.columns.get_level_values(0).drop_duplicates().to_list() | ||
agg: Dict[str, Dict[str, Any]] = {col: {} for col in agg_in_pivot_df} | ||
df_rolling.columns = [ | ||
_flatten_column_after_pivot(col, agg) for col in df_rolling.columns | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will create a separate PR for refactoring _flatten_column_after_pivot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for this fix+added code coverage! 🎉
* fix: rolling and cum operator on multiple series * add UT * updates (cherry picked from commit fd84614)
* fix: rolling and cum operator on multiple series * add UT * updates
* fix: rolling and cum operator on multiple series * add UT * updates
SUMMARY
Currently,
Rolling Window
calculation results are incorrect on multiple series.Frontend codes at: apache-superset/superset-ui#1386
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
After
Before
TESTING INSTRUCTIONS
birth_names
datasettime-series
chartyear
1970 - 2000
sum__num
gender
sum
2
2
ADDITIONAL INFORMATION