-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
read_json tz handling when it's just a list #6864
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
Comments
I dont' think json currently handles tz at all (normally json is UTC, but in theory could be anything). |
So at a glance it looks like JSON uses In [1]: import pandas as pd
In [2]: pd.version.version
Out[2]: '0.13.1-630-gea883e0'
In [3]: pd.Timestamp("2012-03-01T00:05:55+00:00")
Out[3]: Timestamp('2012-03-01 00:05:55+0000', tz='UTC')
In [4]: pd.to_datetime("2012-03-01T00:05:55+00:00")
Out[4]: Timestamp('2012-03-01 00:05:55')
In [5]: pd.DatetimeIndex(["2012-03-01T00:05:55+00:00", "2012-03-01T00:06:23+00:00", "2012-03-01T00:06:52+00:00", "2012-03-01T00:11:23+00:00", "2012-03-01T00:12:47+00:00", "2012-03-01T00:12:54+00:00", "2012-03-01T00:16:14+00:00", "2012-03-01T00:17:31+00:00", "2012-03-01T00:21:23+00:00", "2012-03-01T00:21:26+00:00", "2012-03-01T00:22:25+00:00", "2012-03-01T00:28:24+00:00", "2012-03-01T00:31:21+00:00", "2012-03-01T00:32:20+00:00", "2012-03-01T00:33:32+00:00", "2012-03-01T00:35:21+00:00", "2012-03-01T00:38:14+00:00", "2012-03-01T00:39:24+00:00", "2012-03-01T00:43:12+00:00", "2012-03-01T00:46:13+00:00", "2012-03-01T00:46:31+00:00", "2012-03-01T00:48:03+00:00", "2012-03-01T00:49:34+00:00", "2012-03-01T00:49:54+00:00", "2012-03-01T00:55:19+00:00", "2012-03-01T00:56:27+00:00", "2012-03-01T00:56:32+00:00"])
Out[5]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-03-01 00:05:55+00:00, ..., 2012-03-01 00:56:32+00:00]
Length: 27, Freq: None, Timezone: UTC
In [6]: pd.to_datetime(["2012-03-01T00:05:55+00:00", "2012-03-01T00:06:23+00:00", "2012-03-01T00:06:52+00:00", "2012-03-01T00:11:23+00:00", "2012-03-01T00:12:47+00:00", "2012-03-01T00:12:54+00:00", "2012-03-01T00:16:14+00:00", "2012-03-01T00:17:31+00:00", "2012-03-01T00:21:23+00:00", "2012-03-01T00:21:26+00:00", "2012-03-01T00:22:25+00:00", "2012-03-01T00:28:24+00:00", "2012-03-01T00:31:21+00:00", "2012-03-01T00:32:20+00:00", "2012-03-01T00:33:32+00:00", "2012-03-01T00:35:21+00:00", "2012-03-01T00:38:14+00:00", "2012-03-01T00:39:24+00:00", "2012-03-01T00:43:12+00:00", "2012-03-01T00:46:13+00:00", "2012-03-01T00:46:31+00:00", "2012-03-01T00:48:03+00:00", "2012-03-01T00:49:34+00:00", "2012-03-01T00:49:54+00:00", "2012-03-01T00:55:19+00:00", "2012-03-01T00:56:27+00:00", "2012-03-01T00:56:32+00:00"])
Out[6]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-03-01 00:05:55, ..., 2012-03-01 00:56:32]
Length: 27, Freq: None, Timezone: None |
Regarding the date detection and conversion this works if targeting a series In [60]: json.read_json('["2012-03-01T00:05:55+00:00"]', typ='series')
Out[60]:
0 2012-03-01 00:05:55
dtype: datetime64[ns] however DataFrame only converts "date-like" columns which it deems to be col.endswith('_at') or
col.endswith('_time') or
col.lower() == 'modified' or
col.lower() == 'date' or
col.lower() == 'datetime'): Personally I'm inclined to close as not a bug, as it works as intended (although I didn't author this code). The fix here I think is to target a Series, but I'm happy to update the docs to reflect what I've said above. |
Ah, so one part of this is a
This seems to be discussed in #6415. I remember this |
right...let's close this in favor of #6415 (which is an open issue) |
http://stackoverflow.com/questions/22995828/json-extension-file-timestamp-pandas-python
Perhaps two parts here, first date is not converted unless col is passed in this example. Also tz is lost (I thought it should be 0 somewhere e.g. utcoffset).
The text was updated successfully, but these errors were encountered: