BUG: pd.DateOffset(n) doesn't add days to pd.Series or pd.DatetimeIndex · Issue #45643 · pandas-dev/pandas (original) (raw)
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 pandas as pd
start_date= "20200101" end_date= "20200201"
start_date_1= "20200102" end_date_1= "20200202"
date_range= pd.date_range(start_date, end_date) date_range_1= pd.date_range(start_date_1, end_date_1)
assert all(date_range_1 == date_range + pd.DateOffset(1))
Issue Description
pd.DateOffset(n) doesn't add days to pd.Series or DatetimeIndex like pandas==1.3.5.
Expected Behavior
With pandas==1.3.5, pd.DateOffset(n) should add n days to a vector (pd.Series or DatetimeIndex) /date. But with pandas==1.4.0, it works for date but not for vectors.
You can test it with the reproductible code with pandas version 1.4.0 and 1.3.5 :
version 1.3.5 :
version 1.4.0 :
Installed Versions
INSTALLED VERSIONS
commit : bb1f651
python : 3.9.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19043
machine : AMD64
processor : Intel64 Family 6 Model 165 Stepping 2, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 1.4.0
numpy : 1.22.1
pytz : 2021.3
dateutil : 2.8.2
pip : 21.2.4
setuptools : 58.0.4
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
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None