Skip to content
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

Closed
jreback opened this issue May 21, 2017 · 3 comments · Fixed by #18361
Closed

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

jreback opened this issue May 21, 2017 · 3 comments · Fixed by #18361
Labels
Bug Datetime Datetime data dtype Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timezones Timezone data dtype
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented May 21, 2017

In [1]: Series([Timestamp('20130101'), Timestamp('20130101', tz='US/Eastern')])
Out[1]: 
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)
Out[2]: 
0          2013-01-01 00:00:00
1    2013-01-01 00:00:00-05:00
dtype: object
@jreback jreback added Bug Difficulty Intermediate Reshaping Concat, Merge/Join, Stack/Unstack, Explode Datetime Datetime data dtype Timezones Timezone data dtype labels May 21, 2017
@jreback jreback added this to the Next Major Release milestone May 21, 2017
@theodoreschen
Copy link

theodoreschen 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)
Out[10]:
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')])
Out[11]:
0    2013-01-01 00:00:00+00:00
1    2013-01-01 00:00:00-05:00
dtype: object

@jreback
Copy link
Contributor Author

jreback commented May 25, 2017

@theairportexplorer no!

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

@jamestran201
Copy link

The rough code path for this call Series([Timestamp('20130101'), Timestamp('20130101', tz='US/Eastern')]) is:
series.py.Series.__init__ (263): _sanitize_array()
series.py.Series._sanitize_array (3179): maybe_cast_to_datetime()
cast.py.maybe_cast_to_datetime (1044): maybe_infer_to_datetimelike()
cast.py.maybe_infer_to_datetimelike (914): try_datetime
cast.py.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?
cast.py.try_datetime(890): tools/datetimes.py.to_datetime()
tools/datetimes.py.to_datetime (466): _convert_listlike
tools/datetimes.py._convert_listlike (361): tslib.array_to_datetime -> ValueError
tools/datetimes.py._conver_listlike (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
Labels
Bug Datetime Datetime data dtype Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants