Generate a sequence of weekday dates within a specified date range, optionally excluding weekends and holidays.
Parameters
Name
Type
Description
Default
start_date
str or datetime or pd.DatetimeIndex
The start date of the date range.
required
end_date
str or datetime or pd.DatetimeIndex
The end date of the date range.
required
sunday_to_thursday
bool
If True, generates a sequence with Sunday to Thursday weekdays (excluding Friday and Saturday). If False (default), generates a sequence with Monday to Friday weekdays.
False
remove_holidays
(bool, optional)
If True, excludes holidays (based on the specified country) from the generated sequence. If False (default), includes holidays in the sequence.
False
country
str
The name of the country for which to generate holiday-specific sequences. Defaults to None, which uses the United States as the default country.
None
engine
str
The engine parameter is used to specify the engine to use for generating a weekday series. It can be either “pandas” or “polars”. - The default value is “pandas”. - When “polars”, the function will internally use the polars library for generating a weekday series. This can be faster than using “pandas” for large datasets.
'pandas'
Returns
Type
Description
pd.Series
A Series containing the generated weekday dates.
Examples
import pandas as pdimport pytimetk as tk# United States has Monday to Friday as weekdays (excluding Saturday and # Sunday and holidays)tk.make_weekday_sequence("2023-01-01", "2023-01-15", sunday_to_thursday =False, remove_holidays =True, country ='UnitedStates', engine ='pandas')
# Israel has Sunday to Thursday as weekdays (excluding Friday and Saturday # and Israel holidays)tk.make_weekday_sequence("2023-01-01", "2023-01-15", sunday_to_thursday =True, remove_holidays =True, country ='Israel', engine ='pandas')
# Israel has Sunday to Thursday as weekdays (excluding Friday and Saturday # and Israel holidays)tk.make_weekday_sequence("2023-01-01", "2023-01-15", sunday_to_thursday =True, remove_holidays =True, country ='Israel', engine ='polars')