I'm trying to specify business days in a foreign country, but I can't get the pandas function pd.bdate_range()
to recognize holidays. My code is as follows:
import pandas as pd
import datetime
weekmask = "Mon Tue Wed Thu Fri"
holidays = [datetime.datetime(2017, 1, 9), datetime.datetime(2017, 3, 20),
datetime.datetime(2017, 4, 13)]
BdaysCol2017 = pd.bdate_range(start = pd.datetime(2017, 1, 1),
end = pd.datetime(2017, 12, 31),
weekmask = weekmask,
holidays = holidays)
But I get the following error on the holidays
parameter:
ValueError: a custom frequency string is required when holidays or weekmask are passed, got frequency B
Why is this? How can I specify custom holidays? Is there a better way to do this?
Thank you
as the docs specify about weekmask and holidays:
only used when custom frequency strings are passed
so you need:
BdaysCol2017 = pd.bdate_range(start = pd.datetime(2017, 1, 1),
end = pd.datetime(2017, 12, 31),
freq='C',
weekmask = weekmask,
holidays=holidays)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With