Skip to content

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

Merged
merged 14 commits into from
Sep 7, 2021

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke added the Window rolling, ewma, expanding label Aug 27, 2021
@mroeschke mroeschke added this to the 1.4 milestone Aug 27, 2021
@@ -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
Copy link
Contributor

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?

Copy link
Member Author

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

@mroeschke mroeschke merged commit 6a5dd0f into pandas-dev:master Sep 7, 2021
@mroeschke mroeschke deleted the bug/mi_columns_rolling_corr branch September 7, 2021 05:18
feefladder pushed a commit to feefladder/pandas that referenced this pull request Sep 7, 2021
* BUG: rolling.corr with MultiIndex columns

* Add commentary of fix

* Trigger CI

* Use from_arrays

* Consider reordering
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiIndex Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rolling correlation for DataFrame with MultiIndex columns broken in Pandas 0.23
2 participants