Skip to content
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

REGR: midx.values resetting freq of underyling index #49080

Merged
merged 1 commit into from Oct 14, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Oct 14, 2022

We can not reset the freq with a shallow copy, since the freq is an attribute of the underlying DatetimeArray. A deep copy would cost performance, but calling take before converting to object nicely solves this issue.

@phofl phofl added Regression Functionality that used to work in a prior pandas version MultiIndex labels Oct 14, 2022
@phofl phofl added this to the 1.5.1 milestone Oct 14, 2022
if isinstance(vals, ABCDatetimeIndex):
is_dti = isinstance(vals, ABCDatetimeIndex)

if is_dti:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the same thing happen to TimedeltaIndex?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the underlying TimeDelta objects don't have the freq, so as type(object) a couple of lines below this return the correct objects without resetting the freq

@mroeschke mroeschke merged commit 599f94f into pandas-dev:main Oct 14, 2022
@mroeschke
Copy link
Member

Thanks @phofl

meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Oct 14, 2022
phofl added a commit that referenced this pull request Oct 14, 2022
…of underyling index) (#49094)

Backport PR #49080: REGR: midx.values resetting freq of underyling index

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
@phofl phofl deleted the 49054 branch October 14, 2022 23:09
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiIndex Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: freq information lost after stack() is called
2 participants