-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
API DesignDatetimeDatetime data dtypeDatetime data dtypeFrequencyDateOffsetsDateOffsetsTestingpandas testing functions or related to the test suitepandas testing functions or related to the test suitegood first issue
Milestone
Description
#5637 has some examples as well
When the end date in date_range
is not a valid business day it appears that date_range
first sets it to a valid date before deciding whether to return the last date depending on whether the interval is closed or open on the right. This results in the date range being incorrectly truncated when the interval is open-right - e.g.
In [22]: for d in pd.date_range('20-Mar-2014', '23-Mar-2014', freq='D'):
...: print d.strftime('%a %d-%b-%Y')
...:
Thu 20-Mar-2014
Fri 21-Mar-2014
Sat 22-Mar-2014
Sun 23-Mar-2014
In [23]: pd.date_range('20-Mar-2014', '23-Mar-2014', freq='B')
Out[23]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2014-03-20, 2014-03-21]
Length: 2, Freq: B, Timezone: None
In [24]: # should return all valid business days <= '23-Mar-2014'
...: pd.date_range('20-Mar-2014', '23-Mar-2014', freq='B', closed='left')
<class 'pandas.tseries.index.DatetimeIndex'>
[2014-03-20]
Length: 1, Freq: B, Timezone: None
Metadata
Metadata
Assignees
Labels
API DesignDatetimeDatetime data dtypeDatetime data dtypeFrequencyDateOffsetsDateOffsetsTestingpandas testing functions or related to the test suitepandas testing functions or related to the test suitegood first issue