python-holidays

Passing an array of countries to a function

余生长醉 提交于 2020-02-23 07:14:27
问题 I am fairly new to Python. I am leveraging Python's holidays package which has public holidays by country. I am looking to write a function that loops over any number of countries and returns a dataframe with 3 columns: Date, Holiday, Country Based on my limited knowledge, I came up with this sort of implementation: import holidays def getholidayDF(*args): holidayDF = pd.DataFrame(columns=['Date','Holiday','Country']) for country in args: holidayDF.append(sorted(holidays.CountryHoliday