-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Handling of end
in date_range
#16354
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
Comments
Some related issues: #15886, #12355 Regarding the explanation of Apart from that, your question on how to easily create a DatetimeIndex that certainly includes the end date, is still open (#12355 made a similar request, but what not really discussed) |
related to #6673 as well. |
re jreback's comment, i don't think closed affects any of these
…On 15 May 2017 8:01 pm, "Jeff Reback" ***@***.***> wrote:
related to #6673 <#6673> as
well.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#16354 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz675oRAlb1ZGIn5Euoo40hT8dXLy7ks5r6CKBgaJpZM4NatNL>
.
|
I agree, |
Yeah, I don't know the exact internals enough to assess whether it is the same issue or not .. :-) @jnothman Regarding your second point:
I think this is correct, because 'M' is actually a shorthand for 'month end' (not month start). And so the first month end (January 31) is not included in the start/end range you specify. If you specify month start as the freq explicitly, it is not empty:
|
I suppose I had expected something more akin to |
@jnothman You might want periods then:
which does actually go until the month the 'end' belongs to (so to make sure 'end' is included in the range) |
yes i considered them right after i wrote this issue. but i feel correct
behaviour is not clear here regardless
…On 16 May 2017 12:37 am, "Joris Van den Bossche" ***@***.***> wrote:
@jnothman <https://github.com/jnothman> You might want periods then:
In [62]: pd.period_range(start='2017-01-01', end='2017-02-16', freq='M')
Out[62]: PeriodIndex(['2017-01', '2017-02'], dtype='period[M]', freq='M')
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16354 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz68BGrQm9YIDPI2IEpsCmyozG5_Dqks5r6GMagaJpZM4NatNL>
.
|
Can you clarify that? |
+1 on this issue. For example, if I generate the following index, based on the documentation, I would expect the first date in the generated date range to be "start", and the last date in the generated range to be greater than or equal to "end". That's not what's happening. In certain cases, neither parameter is respected:
|
Another +1. Some more on SO: https://stackoverflow.com/questions/37890391/ Seems to me that the only difference between
I also find the interaction with the default
|
end
in DatetimeIndexend
in date_range
The documentation of
date_range
'send
parameter says:I interpret this to mean that either:
The first interpretation is clearly not true.
But it seems like the second is not certainly true either:
I am not sure if the behaviour with this unequal freq (like
M
which should extract the beginning of the month) is correct. Is this a bug?Otherwise the documentation needs clarification.
More generally, it seems like the implementation is inegalitarian between starts and ends: you can't easily construct a
DatetimeIndex
based onfreq
which certainly includesend
. One approach you could consider is to swapstart
andend
, but without changingfreq
this produces an emptyDatetimeIndex
. Negatingfreq
is possible if it has a unit (e.g.-7d
) but I don't think there's a way to get getfreq='M'
backwards.So three potential sub-issues:
date_range
'send
(and relatedend
params).DateOffset
s is intended.date_range
that starts at an endpoint and applies aDateOffset
in reverse. (Perhaps this is the same as 2.)The text was updated successfully, but these errors were encountered: