-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Add end and end_day options for origin from resample #37805
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
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.
for consistency i thing end_day should also be added?
@@ -1404,15 +1404,18 @@ def __init__( | |||
self.fill_method = fill_method | |||
self.limit = limit | |||
|
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.
can you edit the doc-string and add a versionupdate 1.2 tag (mention that end is added).
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.
sure
i think this is an edge case, but no big deal to add. |
cc @mroeschke |
@@ -1404,15 +1404,18 @@ def __init__( | |||
self.fill_method = fill_method | |||
self.limit = limit | |||
|
|||
if origin in ("epoch", "start", "start_day"): | |||
if origin in ("epoch", "start", "start_day", "end"): | |||
if origin == "end" and self.closed == "left": |
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.
Do you know if we have a similar constraint/check for if origin == "start" and self.closed == "right":
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.
No, now start
use left
by default (except for ‘M’, ‘A’, ‘Q’, ‘BM’, ‘BA’, ‘BQ’, and ‘W’).
Thus I will make a change to allow left
yet still use right
as default setting for end
, this may be more consistent.
rng = date_range(start, end, freq="7min") | ||
ts = Series(np.arange(len(rng)) * 3, index=rng) | ||
|
||
# test consistency of backward and origin |
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.
Can you split up this large test into multiple smaller tests? (one per # comment
would be good)
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.
done, cc @mroeschke
I will rewrite this part of user guide. Need detail enhancement description in whatsnew? Thanks for doc-string, tests, codes review. |
|
||
|
||
# test data for backward resample GH#37804 | ||
start, end = "2000-10-01 23:30:00", "2000-10-02 00:26:00" |
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 think it's okay just to redefine this in every one of the tests below
pandas/core/generic.py
Outdated
|
||
.. versionadded:: 1.2.0 | ||
|
||
backward : bool, default is None |
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.
if anything this should be a separate issue / PR discussion. I actually am -1 on adding this as yet another keyword.
pls revert everything in this PR and focus only on adding the end/end_day), though then do these become useless?
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.
Sorry for adding without discussion. I will make the reversion in this pr. Maybe the backward resampling on an arbitrary Timestamp needs a new strategy instead of new keyword. (origin=('20201129', 'B') seems to be a possible solution, but a little strange to take this tuple input?)
This reverts commit b492293.
This reverts commit 77fc4a3.
This reverts commit 7d8d67a.
This reverts commit 115c92a.
This reverts commit 5b7f396.
This reverts commit 9f4844a.
This reverts commit 0e2e390.
This reverts commit a4e0a39.
This reverts commit 7c54839.
This reverts commit a33acac.
This reverts commit 3442e00.
This reverts commit 2ee1000.
This reverts commit eae898c.
This reverts commit 90c9c5f.
This reverts commit 222ef8d.
This reverts commit d096ccd.
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff