-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Series astype() doesn't convert int64 to datetime64 using M8[D] anymore #3969
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
this is on purpose, try this for converting from epoch (the docs for this are not fully merged yet): I have never seen anyone specify epoch as you have an mean Days....what is the use case (most epcoh
I guess could add
|
In my use case I'm importing data from a SAS data set. SAS stores dates internally as the number of days since 1/1/1960. I could convert that into a string, and from a string into a datetime, but that's far slower than taking the value in as an int, adding a pre-computed number of days to adjust it to 1/1/1970, and then converting that int into a datetime with M8[D]. I can convert to seconds as you suggest, assuming leap seconds will always be ignored. Thanks for your response. I'll close the case. |
@mtkni ok to leave open....will leave this an open issue to add 'D' to units though pandas/numpy will always be since 1/1/1970 (but that's a diff issue) feel free to do a PR! |
@mtkni we disabled the non-ns datetimetypes (and conversions from) because you can get really weird results ....hopefully |
closed via #3973 |
add
units='D'
toTimestamp/to_datetime
epoch supportI have an int64 series representing days since epoch which I'd like to convert to datetime64.
This works in 11.0 but raises an exception in 0.11.1.dev-964516a. The exception message is "TypeError: cannot convert datetimelike to dtype [datetime64[D]]".
My workaround is:
The text was updated successfully, but these errors were encountered: