Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: pd.DateOffset(n) doesn't add days to pd.Series or pd.DatetimeIndex #45643

Closed
2 of 3 tasks
wenceslas-sanchez opened this issue Jan 26, 2022 · 5 comments · Fixed by #45909
Closed
2 of 3 tasks

BUG: pd.DateOffset(n) doesn't add days to pd.Series or pd.DatetimeIndex #45643

wenceslas-sanchez opened this issue Jan 26, 2022 · 5 comments · Fixed by #45909
Labels
Bug Frequency DateOffsets Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@wenceslas-sanchez
Copy link

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 :

image

version 1.4.0 :

image

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

@wenceslas-sanchez wenceslas-sanchez added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 26, 2022
@wenceslas-sanchez wenceslas-sanchez changed the title BUG: BUG: pd.DateOffset(n) doesn't add days to pd.Series or pd.DatetimeIndex Jan 26, 2022
@phofl
Copy link
Member

phofl commented Jan 26, 2022

You have to tell the offset what unit to add, try pd.DateOffset(days=1)

@wenceslas-sanchez
Copy link
Author

Ah yeah indeed ! 😄

But no depreciation warning was raised, when sometimes future argument behavior changing had raised depreciation warning. Is that normal ?

@wenceslas-sanchez
Copy link
Author

Ah yeah indeed ! 😄

But no depreciation warning was raised, when sometimes future argument behavior changing had raised depreciation warning. Is that normal ?

And more, pd.DateOffset(1) worked for date (not vector), that's strange ..

@phofl
Copy link
Member

phofl commented Jan 26, 2022

Can not help you there. I do not use DateOffset with n myself

@iajoiner
Copy link
Contributor

iajoiner commented Feb 9, 2022

I encountered the same problem. Since I can't actually reopen this issue I opened #45890. As @wenceslas-sanchez said something strange has happened and we need to figure out why.

@simonjayhawkins simonjayhawkins added Frequency DateOffsets Regression Functionality that used to work in a prior pandas version and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 10, 2022
@simonjayhawkins simonjayhawkins added this to the 1.4.1 milestone Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Frequency DateOffsets Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants