-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Fix frame_or_series.asfreq() dropping rows on unordered indices #40384
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
Conversation
also pls add a whatsnew note, 1.3. bug fixes, resample section |
@jreback Look good? |
@jreback I just changed the test to resemble the previous test in format. Hopefully, that makes its intention more clear? |
expected = result.copy().reindex(sorted(index)) | ||
|
||
result = result.asfreq("D") | ||
expected = expected.asfreq("D") |
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.
right after L101, do this instead
expected.index = expected.index._with_freq('D')
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.
👍
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 couldn't use ._with_freq('D')
; it failed with an assertion error because it expects None
or 'infer'
.
I used infer.
thanks @nmay231 |
asfreq
silently drops rows when index is not sorted #39805This prevents
frame_or_series.asfreq()
from dropping rows/items if the index is not sorted.This seemed like a relatively easy fix, and it should probably be done sooner than later. However, there wasn't much discussion in the issue so I still have some questions:
a. Silently "sort" the index before reindexing. Or we could
b. Raise a warning before "sorting." Or
c. Raise an error.
asfreq
tests from class-based to functions. Can I do that in this PR or should I do that in another one?