Closed
Description
In [2]: ts_string = '2013-01-01 00:00:00'
In [3]: pd.Series([ts_string], dtype='datetime64[ns, CET]')
Out[3]:
0 2013-01-01 01:00:00+01:00
dtype: datetime64[ns, CET]
In [4]: pd.Series([pd.Timestamp(ts_string, tz='CET')])
Out[4]:
0 2013-01-01 00:00:00+01:00
dtype: datetime64[ns, CET]
Problem description
It appears that a Series will localize a naive string to UTC first and then convert it to the specified timezone specified in dtype
instead of immediately localizing the Series to the timezone.
Note: It looks to work correctly for numeric timestamps:
In [11]: ts = 1.5e15
In [12]: pd.Series([ts], dtype='datetime64[ns, CET]')
Out[12]:
0 1970-01-18 09:40:00+01:00
dtype: datetime64[ns, CET]
In [13]: pd.Series([pd.Timestamp(ts, tz='CET')])
Out[13]:
0 1970-01-18 09:40:00+01:00
dtype: datetime64[ns, CET]
Expected Output
Out[4]:
0 2013-01-01 00:00:00+01:00
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: 0d676a3ccf1d7aa986416a7488b941496f936d98
python: 2.7.13.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-45-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None
pandas: 0.21.0.dev+405.g0d676a3
pytest: 3.2.1
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.26
numpy: 1.13.1
scipy: 0.19.1
pyarrow: None
xarray: None
IPython: 5.3.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: 4.3.2
html5lib: 0.9999999
sqlalchemy: 1.1.13
pymysql: 0.7.9.None
psycopg2: 2.7.1 (dt dec pq3 ext lo64)
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None