-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
FutureWarning: casting datetime64[ns] values to int64 with .astype(...) is deprecated #5146
Comments
Sounds like a straightforward PR to make from the error message, but then if so I'm not sure why it's deprecated and not simply done automatically any more, so maybe there is more to it than that. |
Yeah, I don't really understand the reasoning behind this change tbh. We rely on this a lot all over the place iirc. |
The warning was added here: pandas-dev/pandas#38544 |
Oh my; that link leads to a lot of discussion: pandas-dev/pandas#22384 (comment) I'm not at all sure that the issue has been resolved one way or another, i.e. whether the deprecation will be implemented or reverted, so I'd be inclined to wait on this until such a change is released definitively in pandas. |
The change will also not be as straightforward as the error message for Holoviews, which also can handle Dask DataFrames and Series, which doesn't have a view attribute. So a function to convert would look something like this: def convert_to_int64(x):
if pd.isna(x).any():
raise ValueError("Cannot convert NaN/NaT values to integer")
if dd and isinstance(x, (dd.DataFrame, dd.Series)): # Dask does not have view
return x.astype("int64")
else:
return x.view("int64") |
Ugh! Yes, let's not make this change until we are certain we will need it. |
FYI, the deprecation warning has been reverted |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
ALL software version info
Description of expected behavior and the observed behavior
Casting datetime64[ns] values to int64 with .astype(...) is deprecated
Complete, minimal, self-contained example code that reproduces the issue
Stack traceback and/or browser JavaScript console output
The text was updated successfully, but these errors were encountered: