Skip to content

DOC: default value for pd.DateOffset() is 24 hours instead of 1 calendar day #36512

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
GYHHAHA opened this issue Sep 21, 2020 · 7 comments · Fixed by #36516
Closed

DOC: default value for pd.DateOffset() is 24 hours instead of 1 calendar day #36512

GYHHAHA opened this issue Sep 21, 2020 · 7 comments · Fixed by #36516
Labels
Milestone

Comments

@GYHHAHA
Copy link
Contributor

GYHHAHA commented Sep 21, 2020

>>>pd.__version__
1.1.1
>>>ts = pd.Timestamp('2011-3-27 00:00:00', tz='Europe/Helsinki')
>>>ts + pd.DateOffset(days=1)
Timestamp('2011-03-28 00:00:00+0300', tz='Europe/Helsinki')
>>>ts + pd.DateOffset()
Timestamp('2011-03-28 01:00:00+0300', tz='Europe/Helsinki')
>>>ts + pd.DateOffset(hours=24)
Timestamp('2011-03-28 01:00:00+0300', tz='Europe/Helsinki')

The default action for pd.DateOffset seems to be equal to pd.DateOffset(hours=24) instead of pd.DateOffset(days=1).
But the user guide says DateOffset object defaults to 1 calendar day.

捕获

@GYHHAHA GYHHAHA added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 21, 2020
@arw2019
Copy link
Member

arw2019 commented Sep 21, 2020

What would you expect to get instead?

@GYHHAHA
Copy link
Contributor Author

GYHHAHA commented Sep 21, 2020

I want to get Timestamp('2011-03-28 00:00:00+0300', tz='Europe/Helsinki') when use ts + pd.DateOffset().

@arw2019
Copy link
Member

arw2019 commented Sep 21, 2020

Hmmm so I'm not sure whether this is the expected behavior from DateOffset

For your specific use case would round be a solution?

In [7]: ts.round('D')                                                                                  
Out[7]: Timestamp('2011-03-28 00:00:00+0300', tz='Europe/Helsinki')

@GYHHAHA
Copy link
Contributor Author

GYHHAHA commented Sep 21, 2020

Oh, I know how to convert it to this form.
But just that is not matching the doc description.

For example, a Timedelta day will always increment datetimes by 24 hours, while a DateOffset day will increment datetimes to the same time the next day whether a day represents 23, 24 or 25 hours due to daylight savings time.

Thus maybe it's more clear to point out the default value is 24 hours not a calendar day here.

@arw2019
Copy link
Member

arw2019 commented Sep 21, 2020

Ok, makes sense! Are you interested in opening a PR to add this clarification to the doc?

@GYHHAHA
Copy link
Contributor Author

GYHHAHA commented Sep 21, 2020

glad to

@arw2019
Copy link
Member

arw2019 commented Sep 21, 2020

Fantastic. Here's the contributions guide with the instructions

@dsaxton dsaxton changed the title BUG: default value for pd.DateOffset() is 24 hours instead of 1 calendar day DOC: default value for pd.DateOffset() is 24 hours instead of 1 calendar day Sep 21, 2020
@dsaxton dsaxton added Docs and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 21, 2020
@jbrockmendel jbrockmendel added the Frequency DateOffsets label Oct 29, 2020
@jreback jreback added this to the 1.2 milestone Oct 31, 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 a pull request may close this issue.

5 participants