-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Description
Code Sample
dates = pd.date_range(start=pd.datetime(2018,1,1), periods=4, freq='h', tz='UTC')
print(dates)
print(dates.tz_convert('Etc/GMT+1'))
print(dates.tz_convert('Europe/Rome'))
output:
DatetimeIndex(['2018-01-01 00:00:00+00:00', '2018-01-01 01:00:00+00:00',
'2018-01-01 02:00:00+00:00', '2018-01-01 03:00:00+00:00'],
dtype='datetime64[ns, UTC]', freq='H')
DatetimeIndex(['2017-12-31 23:00:00-01:00', '2018-01-01 00:00:00-01:00',
'2018-01-01 01:00:00-01:00', '2018-01-01 02:00:00-01:00'],
dtype='datetime64[ns, Etc/GMT+1]', freq='H')
DatetimeIndex(['2018-01-01 01:00:00+01:00', '2018-01-01 02:00:00+01:00',
'2018-01-01 03:00:00+01:00', '2018-01-01 04:00:00+01:00'],
dtype='datetime64[ns, Europe/Rome]', freq='H')
Problem description
Converting midnight UTC ('2018-01-01 00:00:00+00:00'
) to GMT+1 (Etc/GMT+1
) should return 1 AM ('2018-01-01 01:00:00+01:00'
), but returns 11 PM ('2017-12-31 23:00:00-01:00'
), which is one hour behind instead of one hour ahead.
Using Europe/Rome
returns the correct output, so I tend to think this is specifically related to time zones using GMT
as reference.
Looking at the outputs, it seems the error might actually come from the numpy
datetime64
type, which has -01:00
as timezone indicator for GMT+1
.
Maybe I am missing something, since it is very odd this hasn't been spotted before.
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.23.0
pytest: 3.0.7
pip: 10.0.1
setuptools: 38.5.1
Cython: 0.25.2
numpy: 1.13.3
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 5.3.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.2.0
openpyxl: 2.4.7
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.3
bs4: 4.6.0
html5lib: 0.999
sqlalchemy: 1.1.9
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None