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

BUG: df.resample('MS', closed='right') incorrectly places bins #55283

Merged

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Sep 25, 2023

todo: extra tests for 'B' with closed ='right' (linked issue below), whatsnew

This fixes a regression from 2.1.0 - but, it also happens to fix two older bugs as a side-effect. So, I've put this in the 2.1.2 milestone

Comment on lines 661 to +663
bs = s.resample("B", closed="right", label="right").mean()
result = bs.resample("8H").mean()
assert len(result) == 22
assert len(result) == 25
Copy link
Member Author

Choose a reason for hiding this comment

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

this was wrong to begin with #55282

now it at least mirrors the behaviour of 'MS', which may have empty buckets at the end, but at least doesn't show wrong results #55284

@mroeschke mroeschke added the Resample resample method label Sep 25, 2023
@MarcoGorelli MarcoGorelli marked this pull request as ready for review September 26, 2023 10:09
@MarcoGorelli MarcoGorelli added this to the 2.1.2 milestone Sep 26, 2023
@mroeschke mroeschke merged commit 98f5a78 into pandas-dev:main Sep 26, 2023
39 checks passed
@mroeschke
Copy link
Member

Thanks @MarcoGorelli

@lumberbot-app
Copy link

lumberbot-app bot commented Sep 26, 2023

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 2.1.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 98f5a787940e02966f2747edbcbd992f0031c277
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am "Backport PR #55283: BUG: df.resample('MS', closed='right') incorrectly places bins"
  1. Push to a named branch:
git push YOURFORK 2.1.x:auto-backport-of-pr-55283-on-2.1.x
  1. Create a PR against branch 2.1.x, I would have named this PR:

"Backport PR #55283 on branch 2.1.x (BUG: df.resample('MS', closed='right') incorrectly places bins)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@MarcoGorelli
Copy link
Member Author

thanks

ah I put the wrong milestone, this should've just gone into 2.2 as it's just a regression since main, rather than since 2.1

will fixup the whatsnew entry later

@phofl
Copy link
Member

phofl commented Oct 3, 2023

@MarcoGorelli ping on the whatsnews, they cause merge conflicts on all back ports

@MarcoGorelli
Copy link
Member Author

here you go, sorry for the delay #55309

spencerkclark added a commit to spencerkclark/xarray that referenced this pull request Oct 30, 2023
spencerkclark added a commit to spencerkclark/xarray that referenced this pull request Oct 31, 2023
dcherian added a commit to pydata/xarray that referenced this pull request Nov 2, 2023
* Port fix from pandas-dev/pandas#55283 to cftime resample [test-upstream]

* Skip test for pandas versions older than 2.2 [test-upstream]

* Update doc/whats-new.rst

Co-authored-by: Justus Magin <keewis@users.noreply.github.com>

---------

Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
Co-authored-by: Justus Magin <keewis@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resample resample method
Projects
None yet
3 participants