-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
astype attempts to convert datetime64[ms] as nanoseconds when missing value in data #10746
Comments
I guess this is a bug, but you should in general simply use
actually I think the astype should simply raise on anything that isn't quite simple. |
pull-requests are welcome! |
Thanks @jreback, I'll use |
@dschallis gr8!. as an FYI, you almost always want to use |
@jreback Yup, unfortunately I'm reading from a JSON dataset with some missing values for timestamps, so |
http://pandas.pydata.org/pandas-docs/stable/io.html#reading-json are you passing how does the JSON represent missing values? |
@jreback hmm, no, I wasn't using
|
hmm, I think that should work actually (if you provided |
@jreback Interestingly enough, that seems to have the same underlying issue as my original example did, i.e.:
Correctly outputs:
Changing to 'ms' instead of 'ns':
Output:
As before though, I the timestamp gets correctly converted if there are no missing values in the data for milliseconds (only nanosecond conversion works with missing data).
I'll take a look into the root cause if I get a chance tomorrow though! |
was closed by #10776 |
When creating a DataFrame with a millisecond timestamp, created with
dtype='datetime64[ms]'
, this works as expected when there are no missing values in the data:Output:
Adding a missing value to the data causes the values to get parsed as nanoseconds rather than microseconds, which causes an exception:
Output:
Expected output was something like:
This was using python 3.4.2, Pandas 0.16.2.
The text was updated successfully, but these errors were encountered: