Skip to content

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

Closed
wants to merge 44 commits into from
Closed

ENH: Add end and end_day options for origin from resample #37805

wants to merge 44 commits into from

Conversation

GYHHAHA
Copy link
Contributor

@GYHHAHA GYHHAHA commented Nov 13, 2020

@pep8speaks
Copy link

pep8speaks commented Nov 13, 2020

Hello @GYHHAHA! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-11-28 10:31:24 UTC

Copy link
Contributor

@jreback jreback left a 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

Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@jreback jreback added Enhancement Resample resample method labels Nov 26, 2020
@jreback
Copy link
Contributor

jreback commented Nov 26, 2020

i think this is an edge case, but no big deal to add.

@jreback
Copy link
Contributor

jreback commented Nov 26, 2020

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":
Copy link
Member

@mroeschke mroeschke Nov 26, 2020

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":

Copy link
Contributor Author

@GYHHAHA GYHHAHA Nov 27, 2020

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.

@GYHHAHA GYHHAHA changed the title ENH: Add 'end' option in resample's origin ENH: Implement backward resample Nov 27, 2020
rng = date_range(start, end, freq="7min")
ts = Series(np.arange(len(rng)) * 3, index=rng)

# test consistency of backward and origin
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, cc @mroeschke

@GYHHAHA GYHHAHA requested a review from jreback November 28, 2020 02:44
@GYHHAHA
Copy link
Contributor Author

GYHHAHA commented Nov 28, 2020

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"
Copy link
Member

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

@GYHHAHA GYHHAHA requested a review from mroeschke November 28, 2020 11:41

.. versionadded:: 1.2.0

backward : bool, default is None
Copy link
Contributor

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?

Copy link
Contributor Author

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?)

@GYHHAHA GYHHAHA changed the title ENH: Implement backward resample ENH: Add end and end_day options for origin from resample Nov 29, 2020
@GYHHAHA GYHHAHA closed this Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Add 'end' option in resample's origin
4 participants