Questions tagged [python-holidays]

A Python library for generating country, province and state specific sets of holidays on the fly. It aims to make determining whether a specific date is a holiday easy.

Available from https://pypi.org/project/holidays

36 questions
1
vote
1 answer

how to calculate number of working days with python

I have a dataframe (df): year month ETP 0 2021 1 49.21 1 2021 2 34.20 2 2021 3 31.27 3 2021 4 29.18 4 2021 5 33.25 5 2021 6 24.70 I would like to add a column that gives me the number of working days…
Fazia Chenna
  • 125
  • 1
  • 15
1
vote
1 answer

Python Holidays Module: Custom holiday not included in "observed"

I'm trying to figure out why a custom holiday is not showing the "observed" date if the holiday itself lands on a weekend. For example, I added Cesar Chavez Day, which is on 03/31/xxxx. While I was testing out different years, I noticed that Cesar…
1
vote
2 answers

Python: Return list of public holidays for a specific country

I am trying a get a list public holidays for a country using the Python Holidays package. I have tried following the steps on the Git Repo and a number of other tutorial websites but I keep getting: AttributeError: module 'holidays' has no attribute…
emeraldev
  • 13
  • 1
  • 4
1
vote
2 answers

Is there a way in Python to mark the Chinese Holidays in Pandas Time Series

I would like to mark the days in my timeseries (data from china) in an extra column as holiday(boolean true) and non holiday(boolean false). I am new to this topic and at the moment I am trying to figure out the way how to approach this problem. I…
Bab
  • 21
  • 4
1
vote
3 answers

Python: Looping over list of countries for holidays

I am fairly new to Python. I am leveraging Python's holiday package which has public holidays by country. In order to get a country's holiday, you can run something like: sorted(holidays.US(years=np.arange(2014,2030,1)).items() This will give the…
biviz
  • 163
  • 8
1
vote
1 answer

How to change observed holidays in holidays module?

I am new to this python holidays library, so I apologize in advance for any trivial questions that I might be asking. My main problem is that I am not sure how to modify the 'observed' values in holidays. I need a holiday to be observed on a Monday…
0
votes
1 answer

How to use pandas.tseries.holiday with a timeseries different frequency?

This answer shows how to create a column, which contains whether a day is a (US) holiday or not. How can I get this to work with a dataframe, that is not sampled in days like in this example? import pandas as pd from pandas.tseries.holiday import…
0
votes
0 answers

Modelling Holidays using FBProphet

I am using FBProphet to predict future values in my monthly datasets. I noted the following in the documentation. Note that with weekly or monthly aggregated data, many holiday effects will be well-captured by the yearly seasonality, so added…
0
votes
1 answer

Pandas isin holidays.country_holidays incorrectly returns only False on 1st attempt but correct results on 2nd attempt

I'm struggling with the behavior of pandas .isin when checking if local dates are a local holiday. I have a data.frame X with utc timestamps which i convert to local date and keep only one row per date in x_daily: import pandas as pd import…
skeletor
  • 361
  • 1
  • 3
  • 8
0
votes
0 answers

Make a string the argument for a module

My code below has an error that says that the module holidays has no attribute AT. Is there any way in which I can turn a string into an attribute like this? import holidays countrycodes = ["AT","GB","US"] countrydata = {'Date': [],'Holiday Name':…
Macamedia
  • 9
  • 1
0
votes
1 answer

Key Error resulting from apply and lambda function on DataFrame column

I generated a new column displaying the 7th business day of the year and month from this df: YearOfSRC MonthNumberOfSRC 0 2022 3 1 2022 4 2 2022 5 3 …
Hefe
  • 421
  • 3
  • 23
0
votes
0 answers

ValueError: holidays must be a provided as a one-dimensional array

I have this df that contains the first and last of the month and number of business days in each month as determined by the Python holidays library: PredictionTargetDateEOM PredictionTargetDateBOM DayAfterTargetDateEOM business_days 0 2018-12-31…
Hefe
  • 421
  • 3
  • 23
0
votes
1 answer

Use Python Holidays package to get dates of holidays based on holiday names

I have this list of holidays ["New Year's Day", 'Martin Luther King Jr. Day', 'Memorial Day', 'Independence Day', 'Labor Day', 'Thanksgiving', 'Christmas Day', "New Year's Day (Observed)", 'Martin Luther King Jr. Day (Observed)', 'Memorial…
Hefe
  • 421
  • 3
  • 23
0
votes
0 answers

ValueError: Cannot create a NumPy datetime other than NaT with generic units

I have generated this df PredictionTargetDateEOM PredictionTargetDateBOM DayAfterTargetDateEOM business_days 0 2018-12-31 2018-12-01 2019-01-01 20 1 2019-01-31 2019-01-01 …
Hefe
  • 421
  • 3
  • 23
0
votes
0 answers

How to fetch month wise value for below code

I need to fetch number of holidays for month wise for below code code import holidays import calendar india_holidays = holidays.India ( years=2022 ) #print(india_holidays) holiday_count_dict = {} for date, occassion in india_holidays.items (): …
Gomathi
  • 131
  • 9