-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: rolling.corr with MultiIndex columns #43261
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
BUG: rolling.corr with MultiIndex columns #43261
Conversation
mroeschke
commented
Aug 27, 2021
- closes Rolling correlation for DataFrame with MultiIndex columns broken in Pandas 0.23 #21157
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
pandas/core/window/common.py
Outdated
@@ -83,8 +83,18 @@ def dataframe_from_int_dict(data, frame_template): | |||
# mypy needs to know columns is a MultiIndex, Index doesn't | |||
# have levels attribute | |||
arg2.columns = cast(MultiIndex, arg2.columns) | |||
result.index = MultiIndex.from_product( | |||
arg2.columns.levels + [result_index] | |||
# GH 21157 |
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.
thi s is really confusing. you are matching the codes from the original? can you reindex?
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'll add comment to what's going on here, but unfortunately can't reindex here.
This needs to act like a MultiIndex.product
, but instead of taking the product of all original levels + result level independently, the original levels need too be treated like a group first before taking a product
* BUG: rolling.corr with MultiIndex columns * Add commentary of fix * Trigger CI * Use from_arrays * Consider reordering