Appending to DataFrame removes the timezone-awareness · Issue #30238 · pandas-dev/pandas (original) (raw)

Code Sample, a copy-pastable example if possible

import pytz

import pandas as pd

df = pd.DataFrame( {"a": [pd.Timestamp("2019-07-19 07:04:57+0100", tz=pytz.FixedOffset(60))]} ) df.append(df.iloc[0])

Problem description

This returns:

|    | a                         |
|---:|:--------------------------|
|  0 | 2019-07-19 07:04:57+01:00 |
|  0 | 2019-07-19 06:04:57       |

However, I was expecting

|    | a                         |
|---:|:--------------------------|
|  0 | 2019-07-19 07:04:57+01:00 |
|  0 | 2019-07-19 07:04:57+01:00 |

which indeed is what happens if I instead write

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.5.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-72-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 0.25.3
numpy : 1.17.4
pytz : 2019.3
dateutil : 2.8.0
pip : 19.3.1
setuptools : 41.6.0.post20191030
Cython : 0.29.14
pytest : 5.3.1
hypothesis : None
sphinx : 2.2.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.9.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.15.1
pytables : None
s3fs : 0.4.0
scipy : 1.3.3
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None