Skip to content

BUG: DatetimeIndex and Timestamp behave inconsistently with respect to pd.DateOffset #43784

Open
@guyguyguy1234

Description

@guyguyguy1234

  • 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 master branch of pandas.

Reproducible Example

pd.DatetimeIndex([pd.to_datetime('2020-10-25').tz_localize('Europe/Berlin')]) + pd.DateOffset(hours=3) 
returns 
2020-10-25 03:00:00+01:00

while

pd.to_datetime('2020-10-25').tz_localize('Europe/Berlin') + pd.DateOffset(hours=3) 
returns 
Timestamp('2020-10-25 02:00:00+0100', tz='Europe/Berlin')

Issue Description

Mismatch between the outputs.

Here is the stackoverflow post describing in detail the issue.

Expected Behavior

Returning same datetime

Installed Versions

INSTALLED VERSIONS

commit : 73c6825
python : 3.9.4.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
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.3.3
numpy : 1.19.5
pytz : 2021.1
dateutil : 2.8.1
pip : 21.2.4
setuptools : 52.0.0.post20210125
Cython : 0.29.23
pytest : 6.2.3
hypothesis : None
sphinx : 4.0.1
blosc : None
feather : None
xlsxwriter : 1.3.8
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.22.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.9.0
fastparquet : None
gcsfs : None
matplotlib : 3.3.4
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : None
pyxlsb : 1.0.8
s3fs : None
scipy : 1.6.2
sqlalchemy : 1.4.7
tables : None
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : 1.3.0
numba : 0.53.1

Metadata

Metadata

Assignees

Labels

BugDatetimeDatetime data dtypeNumeric OperationsArithmetic, Comparison, and Logical operationsTimezonesTimezone data dtype

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions