Closed
Description
xref #14052
discussed at bit in the original PR: #10477
I think was a mistake to return a datetime64[ns]
in UTC for a tz-aware Series. we should
simply return an object array of Timestamps
, as it round-trips correctly. IOW, you don't lose the timezones.
tz-naive
In [9]: Series(pd.date_range('20130101',periods=3)).values
Out[9]:
array(['2013-01-01T00:00:00.000000000', '2013-01-02T00:00:00.000000000',
'2013-01-03T00:00:00.000000000'], dtype='datetime64[ns]')
tz-aware - currently
In [10]: Series(pd.date_range('20130101',periods=3, tz='US/Eastern')).values
Out[10]:
array(['2013-01-01T05:00:00.000000000', '2013-01-02T05:00:00.000000000',
'2013-01-03T05:00:00.000000000'], dtype='datetime64[ns]')
what we should do
In [15]: np.array(Series(pd.date_range('20130101',periods=3, tz='US/Eastern')).tolist())
Out[15]:
array([Timestamp('2013-01-01 00:00:00-0500', tz='US/Eastern'),
Timestamp('2013-01-02 00:00:00-0500', tz='US/Eastern'),
Timestamp('2013-01-03 00:00:00-0500', tz='US/Eastern')], dtype=object)
round trips are plainly wrong (current)
In [5]: arr = Series(pd.date_range('20130101',periods=3, tz='US/Eastern'))
In [6]: Series(arr.values)
Out[6]:
0 2013-01-01 05:00:00
1 2013-01-02 05:00:00
2 2013-01-03 05:00:00
dtype: datetime64[ns]
round-trips are preserved (proposed)
In [3]: arr = np.array(Series(pd.date_range('20130101',periods=3, tz='US/Eastern')).tolist())
In [4]: Series(arr)
Out[4]:
0 2013-01-01 00:00:00-05:00
1 2013-01-02 00:00:00-05:00
2 2013-01-03 00:00:00-05:00
dtype: datetime64[ns, US/Eastern]
I don't think there is any way to transition to this and we simply have to change it. `