-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Error in pd.to_datetime, with argument np.datetime64 array of 51 elements #31491
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
@pajachiet Thanks for the report! |
The difference between 50 and 51 is from the caching we do in to_datetime pandas/pandas/core/tools/datetimes.py Lines 98 to 101 in ba08390
|
The bug is in unique In [20]: d = np.array([np.datetime64("2000-01-01", "s")])
In [21]: pd.unique(d)
Out[21]: array(['29999249045-07-29T00:00:00'], dtype='datetime64[s]') So we should either handle non-ns datetimes there, or convert to ns before calling it. |
Still working on this. Getting closer, but turned up a second issue with |
Code Sample, a copy-pastable example if possible
Problem description
With pandas 1.0, we get a new issue when using pd.to_datetime to convert an existing np.datetime64 array with 51 elements.
This works with 50 elements, or when converting to a Series beforehand, so I believe the problems comes from inside implicit conversion.
The text was updated successfully, but these errors were encountered: