We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This code works fine
pd.date_range(start='2020-11-25 10:00',periods=14, freq=pd.offsets.CustomBusinessHour(start='10:00'))
but if I add holidays then it produces more than 14 periods
pd.date_range(start='2020-11-25 10:00',periods=14, freq=pd.offsets.CustomBusinessHour(start='10:00',holidays=['2020-11-26']))
Output:
DatetimeIndex(['2020-11-25 10:00:00', '2020-11-25 11:00:00', '2020-11-25 12:00:00', '2020-11-25 13:00:00', '2020-11-25 14:00:00', '2020-11-25 15:00:00', '2020-11-25 16:00:00', '2020-11-27 10:00:00', '2020-11-27 11:00:00', '2020-11-27 12:00:00', '2020-11-27 13:00:00', '2020-11-27 14:00:00', '2020-11-27 15:00:00', '2020-11-27 16:00:00', '2020-11-30 10:00:00', '2020-11-30 11:00:00', '2020-11-30 12:00:00', '2020-11-30 13:00:00', '2020-11-30 14:00:00', '2020-11-30 15:00:00', '2020-11-30 16:00:00', '2020-12-01 10:00:00', '2020-12-01 11:00:00', '2020-12-01 12:00:00', '2020-12-01 13:00:00', '2020-12-01 14:00:00', '2020-12-01 15:00:00', '2020-12-01 16:00:00', '2020-12-02 10:00:00', '2020-12-02 11:00:00', '2020-12-02 12:00:00'], dtype='datetime64[ns]', freq='CBH')
If I replace periods with the corresponding end then everything works fine.
periods
end
pd.date_range(start='2020-11-25 10:00',end='2020-11-27 16:00:00', freq=pd.offsets.CustomBusinessHour(start='10:00',holidays=['2020-11-26']))
I am not sure why date_range has this weird behavior. Appreciate any help.
The text was updated successfully, but these errors were encountered:
This does not explain the behavior but just subseting the output gets the job done.
pd.date_range(start='2020-11-25 10:00',periods=14, freq=pd.offsets.CustomBusinessHour(start='10:00',holidays=['2020-11-26']))[:14]
Edit: Actually this does not work because the code below only produces 13 records, not more than 20
pd.date_range(start='2020-11-25 10:00',periods=20, freq=pd.offsets.CustomBusinessHour(start='10:00',holidays=['2020-11-26']))
Sorry, something went wrong.
This is a bug in applying a custom-business-hour offset onto a datetime.
Will get this fixed.
Not sure whether this is related to the above bug but this one also produces wrong result
pd.Timestamp('2020-11-25 10:00')+ 7*pd.offsets.CustomBusinessHour(start='10:00',holidays=['2020-11-26'])
and
pd.Timestamp('2020-11-25 10:00')+ 8*pd.offsets.CustomBusinessHour(start='10:00',holidays=['2020-11-26'])
Successfully merging a pull request may close this issue.
This code works fine
but if I add holidays then it produces more than 14 periods
Output:
If I replace
periods
with the correspondingend
then everything works fine.I am not sure why date_range has this weird behavior. Appreciate any help.
The text was updated successfully, but these errors were encountered: