Skip to content

BUG: Copying PeriodIndex levels on MultiIndex loses weakrefs #33131

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

Closed
topper-123 opened this issue Mar 29, 2020 · 0 comments · Fixed by #33134
Closed

BUG: Copying PeriodIndex levels on MultiIndex loses weakrefs #33131

topper-123 opened this issue Mar 29, 2020 · 0 comments · Fixed by #33134
Labels
Milestone

Comments

@topper-123
Copy link
Contributor

As per comment by @jacobaustin123:

import pandas as pd
idx = pd.MultiIndex.from_arrays([pd.PeriodIndex([pd.Period("2019Q1"), pd.Period("2019Q2")], name='b')])
idx2 = pd.MultiIndex.from_arrays([idx._get_level_values(level) for level in range(idx.nlevels)])
all(x.is_monotonic for x in idx2.levels) # raises an error

Problem description

The weakly referenced PeriodIndex er dropped before intended, so the PeriodEngine gets a None instead of the PeriodIndex.

Expected Output

The above should return True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant