classification
Title: pandas tz_convert() seems to report incorrect date conversion
Type: Stage: resolved
Components: Versions: Python 3.6
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: Seeking.that, xtreak
Priority: normal Keywords:

Created on 2020-01-01 14:22 by Seeking.that, last changed 2020-01-12 14:40 by cheryl.sabella. This issue is now closed.

Messages (2)
msg359156 - (view) Author: seeking.that (Seeking.that) Date: 2020-01-01 14:22
Hi

python pandas bdate_range tz_convert() seems to have problems as it prints the information incorrectly. Please clarity. The python script and the output is shown below:

Two issues that can be highlighted here are:
1) Setting the timezone correctly to US/Pacific prints the dates correctly. But the conversion causes the date calculations to be incorrect.
2. Minor issue just related to display. Though the API hasn't changed, the last call has more information hh-mm-ss-xx-xx which is not there for the rest of the calls with same format signature.

Thanks
SK
import pandas as pd

c5 = pd.bdate_range(start='1/1/2018', end = '1/31/2018')
print(c5)
c5 = c5.tz_localize('UTC')
print(c5)
c5 = c5.tz_convert('US/Pacific')
print(c5)
c6 = pd.bdate_range(start='1/1/2018', end = '1/31/2018')
print(c6)
c6 = c6.tz_localize('US/Pacific')
print(c6)
------

DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
               '2018-01-05', '2018-01-08', '2018-01-09', '2018-01-10',
               '2018-01-11', '2018-01-12', '2018-01-15', '2018-01-16',
               '2018-01-17', '2018-01-18', '2018-01-19', '2018-01-22',
               '2018-01-23', '2018-01-24', '2018-01-25', '2018-01-26',
               '2018-01-29', '2018-01-30', '2018-01-31'],
              dtype='datetime64[ns]', freq='B')
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
               '2018-01-05', '2018-01-08', '2018-01-09', '2018-01-10',
               '2018-01-11', '2018-01-12', '2018-01-15', '2018-01-16',
               '2018-01-17', '2018-01-18', '2018-01-19', '2018-01-22',
               '2018-01-23', '2018-01-24', '2018-01-25', '2018-01-26',
               '2018-01-29', '2018-01-30', '2018-01-31'],
              dtype='datetime64[ns, UTC]', freq='B')
DatetimeIndex(['2017-12-31', '2018-01-01', '2018-01-02', '2018-01-03',
               '2018-01-04', '2018-01-07', '2018-01-08', '2018-01-09',
               '2018-01-10', '2018-01-11', '2018-01-14', '2018-01-15',
               '2018-01-16', '2018-01-17', '2018-01-18', '2018-01-21',
               '2018-01-22', '2018-01-23', '2018-01-24', '2018-01-25',
               '2018-01-28', '2018-01-29', '2018-01-30'],
              dtype='datetime64[ns, US/Pacific]', freq='B')
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
               '2018-01-05', '2018-01-08', '2018-01-09', '2018-01-10',
               '2018-01-11', '2018-01-12', '2018-01-15', '2018-01-16',
               '2018-01-17', '2018-01-18', '2018-01-19', '2018-01-22',
               '2018-01-23', '2018-01-24', '2018-01-25', '2018-01-26',
               '2018-01-29', '2018-01-30', '2018-01-31'],
              dtype='datetime64[ns]', freq='B')
DatetimeIndex(['2018-01-01 00:00:00-08:00', '2018-01-02 00:00:00-08:00',
               '2018-01-03 00:00:00-08:00', '2018-01-04 00:00:00-08:00',
               '2018-01-05 00:00:00-08:00', '2018-01-08 00:00:00-08:00',
               '2018-01-09 00:00:00-08:00', '2018-01-10 00:00:00-08:00',
               '2018-01-11 00:00:00-08:00', '2018-01-12 00:00:00-08:00',
               '2018-01-15 00:00:00-08:00', '2018-01-16 00:00:00-08:00',
               '2018-01-17 00:00:00-08:00', '2018-01-18 00:00:00-08:00',
               '2018-01-19 00:00:00-08:00', '2018-01-22 00:00:00-08:00',
               '2018-01-23 00:00:00-08:00', '2018-01-24 00:00:00-08:00',
               '2018-01-25 00:00:00-08:00', '2018-01-26 00:00:00-08:00',
               '2018-01-29 00:00:00-08:00', '2018-01-30 00:00:00-08:00',
               '2018-01-31 00:00:00-08:00'],
              dtype='datetime64[ns, US/Pacific]', freq='B')
msg359158 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-01-01 14:33
This tracker is for issues related to CPython. Unless there is a simple reproducer in Python without pandas to illustrate the issues reported I would propose closing this as third party. Please follow this up at https://github.com/pandas-dev/pandas/
History
Date User Action Args
2020-01-12 14:40:45cheryl.sabellasetstatus: open -> closed
2020-01-04 06:36:56terry.reedysetresolution: third party
stage: resolved
2020-01-01 14:33:06xtreaksetnosy: + xtreak
messages: + msg359158
2020-01-01 14:22:26Seeking.thatcreate