BUG: pd.Timestamp loses fold when removing timezone which is inconsistent with datetime.datetime · Issue #37610 · pandas-dev/pandas (original) (raw)


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Problem description

datetime.datetime saves the fold when replacing tzinfo, but pandas.Timestamp doesn't

Code Sample, a copy-pastable example

import dateutil.tz import pandas from datetime import datetime as dt print(pandas.Timestamp(1256427000000000000, tz=dateutil.tz.gettz('Europe/Moscow'), unit='ns'))

Timestamp('2009-10-25 02:30:00+0300', tz='dateutil//usr/share/zoneinfo/Europe/Moscow')

print(pandas.Timestamp(1256427000000000000, tz=dateutil.tz.gettz('Europe/Moscow'), unit='ns').fold)

1

print(pandas.Timestamp(1256427000000000000, tz=dateutil.tz.gettz('Europe/Moscow'), unit='ns').replace(tzinfo=None).fold)

0

print(dt(2009, 10, 25, 2,30, fold=1, tzinfo=dateutil.tz.gettz('Europe/Moscow')).replace(tzinfo=None).fold)

1

Expected Output

Timestamp('2009-10-25 02:30:00+0300', tz='dateutil//usr/share/zoneinfo/Europe/Moscow')
1
1
1

Output of pd.show_versions()

commit : 67a3d42
python : 3.8.4.final.0
python-bits : 64
OS : Darwin
OS-release : 19.5.0
Version : Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.4
numpy : 1.16.4
pytz : 2020.4
dateutil : 2.8.0
pip : 20.1.1
setuptools : 39.0.1
Cython : 3.0a6
pytest : 5.0.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.3 (dt dec pq3 ext lo64)
jinja2 : 2.10.1
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.0.3
numexpr : None
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : 0.8.6
xarray : None
xlrd : 1.2.0
xlwt : None
numba : None