You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a time series dataset that produces data every hour from Monday to Friday and no data on Saturday and Sunday. I am unable to create these time stamps using pd.offsets.BusinessHour. There is an issue with the crossover between days. As you can see above, the timestamp 2000-01-04 00:00:00 is completely missing.
If this is not a bug, could anyone please let me know how to produce these time indices.
BusinessHour is primarily for finding business hours within a day (say, 09:00 to 17:00). It is not particularly for holiday applications.
For your purposes try
importpandasaspdstart_date='2000-01-01'end_date='2023-12-23'# create an hourly date rangedr=pd.date_range(start_date, end_date, freq='H')
# limit to business daysdr=dr[dr.weekday<=4]
Thank you for your response to this problem. Respectfully, I don't think this is a 'holiday' problem. It is indeed a business hour problem, where the business is open 24 hours from Monday to Friday (e.g. foreign exchange markets).
When building a generic app that needs to be work across different frequencies (BH being only one of them), it would be better not to have such code branches for specific frequencies. Would there be an alternate solution to this that can be handled by pandas seamlessly without the need to add such custom code?
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
I have a time series dataset that produces data every hour from Monday to Friday and no data on Saturday and Sunday. I am unable to create these time stamps using
pd.offsets.BusinessHour
. There is an issue with the crossover between days. As you can see above, the timestamp 2000-01-04 00:00:00 is completely missing.If this is not a bug, could anyone please let me know how to produce these time indices.
Expected Behavior
Timestamp '2000-01-04 00:00:00' should be present.
Installed Versions
INSTALLED VERSIONS
commit : a671b5a
python : 3.10.12.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.146.1-microsoft-standard-WSL2
Version : #1 SMP Thu Jan 11 04:09:03 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.4
numpy : 1.26.4
pytz : 2024.2
dateutil : 2.9.0.post0
setuptools : 69.5.1
pip : None
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.30.0
pandas_datareader : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : 2024.12.0
gcsfs : None
matplotlib : 3.10.0
numba : 0.60.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 18.1.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.14.1
sqlalchemy : 2.0.36
tables : None
tabulate : 0.9.0
xarray : None
xlrd : 2.0.1
zstandard : 0.23.0
tzdata : 2024.2
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: