Skip to content

date_range default calendar day return #12705

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
zxymark221 opened this issue Mar 23, 2016 · 4 comments
Closed

date_range default calendar day return #12705

zxymark221 opened this issue Mar 23, 2016 · 4 comments
Labels

Comments

@zxymark221
Copy link

Code Executed:

#0.000016 second less than 24 hours, acrossing 2 calendar day.
print pandas.date_range(start='2016-03-22 12:19:49.053501', end='2016-03-23 12:19:49.053485')

Output of different versions.

  • Prior to 0.17

    Prior to 0.17 versions, I tested 0.16 and 0.13, they both return two days.

    DatetimeIndex(['2016-03-22 12:19:49.053501', '2016-03-23 12:19:49.053501'], dtype='datetime64[ns]', freq='D', tz=None)
  • V0.17 & 0.18

    Returns one day only

    DatetimeIndex(['2016-03-22 12:19:49.053501'], dtype='datetime64[ns]', freq='D')

On the documentation, the freq is set to be calendar daily by default, the test above covers two calendar days, does it make more sense to return two days like the earlier versions do?

@jreback
Copy link
Contributor

jreback commented Mar 23, 2016

This was changed here, because of a bug.

Not really sure what you are trying to do.

@zxymark221
Copy link
Author

@jreback Thanks for your reply.

What I am trying to say is: I am expecting the code execute above should return two days(both 2016-03-22 and 2016-03-23) even though the start and end time I specified above is less than 24 hrs. This is because the freq setting in date_range is by default calendar daily. From my perspective, calendar daily is different from 24 hours, otherwise, why should we call it calendar daily.

@jreback
Copy link
Contributor

jreback commented Mar 23, 2016

@zxymark221 I don't think so. you asked for 1 Day from the start effectively as stop time < start time + 1 day:

In [3]: start = Timestamp('2016-03-22 12:19:49.053501')

In [4]: stop = Timestamp('2016-03-23 12:19:49.053485')

In [6]: start+pd.offsets.Day()
Out[6]: Timestamp('2016-03-23 12:19:49.053501')

In [8]: stop-start+pd.offsets.Day()
Out[8]: Timedelta('1 days 23:59:59.999984')

In [9]: start+pd.offsets.Day() > stop
Out[9]: True

@zxymark221
Copy link
Author

@jreback Thank you. Understood. By default, freq is 24 hours.

I've been using 0.16 version for a long time, and the idea of calendar daily here made me think it will return all the dates the range has been through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants