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
6
votes
2 answers

Add business days to pandas dataframe with dates and skip over holidays python

I have a dataframe with dates as seen in the table below. 1st block is what it should look like and the 2nd block is what I get when just adding the BDays. This is an example of what it should look like when completed. I want to use the 1st column…
dps
  • 139
  • 3
  • 11
3
votes
1 answer

Pandas: Calculate time in minutes between 2 columns, excluding weekends, public holidays and taking business hours into account

I have the below issue and I feel I'm just a few steps away from solving it, but I'm not experienced enough just yet. I've used business-duration for this. I've looked through other similar answers to this and tried many methods, but this is the…
Shaun
  • 33
  • 4
3
votes
1 answer

How can i list all holidays' date for each country using holidays module in python?

I am trying to find holidays' date with holidays package in python for many countries but, instead of writing one by one like this: import holidays for date in holidays.UnitedKingdom(years=2011).items(): print(str(date[0])) for date in…
brKdgl
  • 35
  • 5
2
votes
0 answers

Unable to import holidays from fb prophet package

Getting error while importing holidays from fb prophet as below. Seems like an intermittent issue. import fbprophet.hdays as hdays_part2 TypeError: This is a python-holidays entity loader class. For entity inheritance purposes please import a class…
Sarang Manjrekar
  • 1,839
  • 5
  • 31
  • 61
2
votes
2 answers

Python Identify US holidays in a timeseries dataframe

I have a dataframe with years of data. I want to detect, assign True/False or 1/0 if it is a Holiday. My code: df = pd.DataFrame(index=['2004-10-01', '2004-10-02', '2004-10-03', '2004-10-04', '2004-10-05', '2004-10-06', '2004-10-07',…
Mainland
  • 4,110
  • 3
  • 25
  • 56
2
votes
1 answer

Use the holidays library on python timestamp type under specific conditions

I have the following dataframe: | ID | date | |--------------|-----------------------------------------| | 0 | 2022-01-01 12:00:01+05:00 | | 1 | 2022-01-30…
Carola
  • 366
  • 4
  • 18
2
votes
0 answers

How do i input holidays into statsmodels.tsa.x13.x13_arima_analysis

Many thanks in advance. I've been looking to implement some seasonal decomposition for my analysis and was trying to use the X13 wrapper provided by statsmodel to run it. However, as I am running my seasonal decomposition on data from countries…
joel.tan
  • 41
  • 5
1
vote
3 answers

Python : my code is slow, using for loop with Pandas dataframe

I got this code below which works fine but takes too much time to execute (>30s): df['Date_engagement'] = np.nan for i in range(df.shape[0]): if not(pd.isna(df.loc[i,'Engagement'])): df.loc[i, 'Date_engagement'] = np.busday_offset( …
1
vote
1 answer

Holiday ranking logic - translating from English to Python

I have been trying to wrap my head around a, in theory, simple task, but am having real difficulty coding it up. It is a kind of code test / brain teaser! On page 14 of this document there is a holiday code ruleset that I am trying to translate from…
13sen1
  • 265
  • 2
  • 4
  • 14
1
vote
2 answers

Generate holiday data using python holidays library

I want to create a datafarme with the holidays using the python holiday library. from datetime import date import holidays us_holidays = holidays.US() date(2015, 1, 1) in us_holidays # True date(2015, 1, 2) in us_holidays # False I want to…
Bella_18
  • 624
  • 1
  • 14
1
vote
0 answers

How to pass holiday lower_window /upper_window for weekly aggregated data in prophet time series modelling

Exploring the fb prophet package, I'm below code for passing holidays to daily data time series. superbowls = pd.DataFrame({ 'holiday': 'superbowl', 'ds': pd.to_datetime(['2010-02-07', '2014-02-02', '2016-02-07']), 'lower_window': -1, …
1
vote
0 answers

Python - holidays Countdown and count-up in df

I am new to programming. I want to create 4 columns in an existing french holidays df: Countdown in days till the first day of the next holidays Name of the next holidays related to the countdown Countup in days from the last day of the earliest…
1
vote
1 answer

which holidays been celebrated in particular date and in which countries

i want to know if particular date (in this example today's date) is holiday somwhere in the world. if yes - i would like to create list with tupple, in each tuple - (holiday name, where in the world). if it is not holiday anywhere - empty list. i…
1
vote
1 answer

why do does generating a list of holidays in the year 2005 blow up this function?

I am writing a Python script using datetime, holidays and dateutil to determine if a given date in YYYY-MM-DD format is a trading holiday. I'm using a generator expression to remove holidays where the market is not closed from the default list of…
1
vote
1 answer

Numpy busday_count not considering holidays

I have a dataset and I need to calculate working days from a given date to today, excluding the given list of holidays. I will be including weekends. Date Sample: This is the code I tried: import pandas as pd import numpy as np from datetime import…
Shazib Munshi
  • 49
  • 1
  • 5
1
2 3