Skip to content

BUG: date_range with freq="C" (business days) return value changed on 1.5.0 #49441

Closed
@adamchainz

Description

@adamchainz

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

import datetime as dt
import pandas as pd
import pytz

paris = pytz.timezone("Europe/Paris")
start = dt.datetime.fromisoformat("2022-07-22 22:00:00+00:00").astimezone(paris)
print(pd.date_range(start, periods=1, freq="C"))

Issue Description

On Pandas 1.4.4, the above shows:

DatetimeIndex(['2022-07-25 00:00:00+02:00'], dtype='datetime64[ns, Europe/Paris]', freq='C')

On Pandas 1.5.1, it shows:

DatetimeIndex(['2022-07-23 00:00:00+02:00', '2022-07-25 00:00:00+02:00'], dtype='datetime64[ns, Europe/Paris]', freq='C')

There are no warnings from the previous code.

Expected Behavior

THe same results, unless I have missed something in the release notes (I tried reading all results matching date/time/business, couldn't see anything relevant).

Installed Versions


INSTALLED VERSIONS
------------------
commit           : ca60aab7340d9989d9428e11a51467658190bb6b
python           : 3.10.8.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 21.6.0
Version          : Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000
machine          : arm64
processor        : arm
byteorder        : little
LC_ALL           : None
LANG             : en_GB.UTF-8
LOCALE           : en_GB.UTF-8

pandas : 1.4.4
numpy : 1.23.4
pytz : 2022.6
dateutil : 2.8.2
setuptools : 65.5.0
pip : 22.3
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None

Metadata

Metadata

Labels

BugFrequencyDateOffsetsRegressionFunctionality that used to work in a prior pandas version

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions