New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: construction of tz-naive and tz-aware should not coerce #16406

jreback opened this Issue May 21, 2017 · 3 comments


None yet
3 participants

jreback commented May 21, 2017

In [1]: Series([Timestamp('20130101'), Timestamp('20130101', tz='US/Eastern')])
0   2012-12-31 19:00:00-05:00
1   2013-01-01 00:00:00-05:00
dtype: datetime64[ns, US/Eastern]

should instead be

In [2]: Series([Timestamp('20130101'), Timestamp('20130101', tz='US/Eastern')], dtype=object)
0          2013-01-01 00:00:00
1    2013-01-01 00:00:00-05:00
dtype: object

@jreback jreback added this to the Next Major Release milestone May 21, 2017


This comment has been minimized.

theairportexplorer commented May 25, 2017

Would making tz default to 'UTC' upon Timestamp() declaration be sufficient to fix this bug?

In [10]: pd.Series([pd.Timestamp('20130101'), pd.Timestamp('20130101', tz='US/Eastern')], dtype=object)
0          2013-01-01 00:00:00
1    2013-01-01 00:00:00-05:00
dtype: object

In [11]: pd.Series([pd.Timestamp('20130101', tz='UTC'), pd.Timestamp('20130101', tz='US/Eastern')])
0    2013-01-01 00:00:00+00:00
1    2013-01-01 00:00:00-05:00
dtype: object

This comment has been minimized.


jreback commented May 25, 2017

@theairportexplorer no!

naive and tz-aware UTC are different! The default is naive (has always been and always will).


This comment has been minimized.


tmnhat2001 commented Nov 18, 2017

The rough code path for this call Series([Timestamp('20130101'), Timestamp('20130101', tz='US/Eastern')]) is: (263): _sanitize_array() (3179): maybe_cast_to_datetime() (1044): maybe_infer_to_datetimelike() (914): try_datetime (882): tslib.array_to_datetime()
tslib.pyx array_to_datetime(): raise ValueError because it's trying convert Timestamp('20130101', tz='US/Eastern') to datetime64 with utc=None? tools/
tools/ (466): _convert_listlike
tools/ (361): tslib.array_to_datetime -> ValueError
tools/ (376): tslib.datetime_to_datetime64(arg)
-> array(['2013-01-01T00:00:00.000000000', '2013-01-01T05:00:00:000000000'],dtype=datetime64[ns])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment