Pandasで国民の祝日を除く平日を作成


import pandas as pd

holidays = pd.read_csv(
    "https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv",
    encoding="cp932",
    parse_dates=[0],
)["国民の祝日・休日月日"].values

# 曜日指定
# weekmask_egypt = "Sun Mon Tue Wed Thu Fri Sat"
# bday_egypt = pd.offsets.CustomBusinessDay(holidays=holidays, weekmask=weekmask_egypt)

# 平日
bday_egypt = pd.offsets.CustomBusinessDay(holidays=holidays)

df_dates = pd.date_range("2021-01-01", "2021-01-31", freq=bday_egypt)