-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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: resample with tz-aware: Values falls after last bin #15555
Conversation
jreback, would you like me to add tests for this change ? |
tests! always and a whatsnew note please. |
committed a test and wrote a whatsnew note. |
I understand why the checks failed, I will commit a fix |
@jreback is it ok to change already existing tests in order to make my change pass them ? |
you need to prove that a current test is wrong in order to change it |
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 am not so sure I buy the rationale for the change here. The binning MUST be in the local tz, and NOT UTC, otherwise that is VERY confusing (IOW you would have really odd breakpoints which have nothing to do with the data, but the timezone). T
def test_resample_tz_aware_bug_15549(self): | ||
index = pd.DatetimeIndex([1450137600000000000, 1474059600000000000], tz='UTC').tz_convert('America/Chicago') | ||
df = pd.DataFrame([1, 2], index=index) | ||
df.resample('12h', closed='right', label='right').last().ffill() |
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.
result = df.resample(.......)
expected = ....
tm.assert_frame_equal(result, expected)
add a comment with the issue number as a comment (and not in the test name)
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.
agree, I will fix it. I just used the same notation as in the test above. thought it's a common thing
@@ -2670,6 +2670,11 @@ def test_resample_weekly_bug_1726(self): | |||
# it works! | |||
df.resample('W-MON', closed='left', label='left').first() | |||
|
|||
def test_resample_tz_aware_bug_15549(self): | |||
index = pd.DatetimeIndex([1450137600000000000, 1474059600000000000], tz='UTC').tz_convert('America/Chicago') |
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.
this line is going to be too long for linting.
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.
understood, I will change it
I think you need to compute the range edges with the tz intact. I think it is mishandling when it has an ambiguous datetime. Then constructing the tz should be ok. |
got it, let me try to use your approach |
@ahcub yeah this seemingly trivial change is actually hard. there have been lots of fixes (for various reasons) thru the years. good news is the test suite is quite comprehensive here :> |
can you rebase / update |
I will close it for now and restore it when I get back to it |
@ahcub ok sure. though pls come back when you can! thanks! |
git diff upstream/master | flake8 --diff
7:00 19:00 7:00 19:00
instead of
00:00 12:00 00:00 12:00