-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pandas.to_datetime raises when given pd.NA #32213
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
As mentioned on the PR, I am not fully sure we should convert it to pd.NaT, or at least not until we have a better idea how we want to handle NA in datetime-like dtypes in the future. |
we should absolutely convert this; all null values correctly convert to the current missing value NaT |
Part of my concern is that having errors like these could discourage people from using NA and nullable types in general. For example, suppose someone takes the reasonable steps of storing date strings along with missing values in a string dtype and then wants to convert them using pd.to_datetime. Getting an error here creates an unnecessary edge case that people then may try to avoid by not using the types. It seems you'd want to have it return the "usual" output in the short term even if the plan is to have a special NA sentinel for timestamps in the long term. |
+1 to having this convert as well |
Note that for the conversion the other way around (from nullable dtype to a dtype that uses np.nan), we decided that we (for now) don't want to do implicit conversion of pd.NA to np.nan, since that has different behaviour. The example case of @dsaxton is a good one though, and I agree it would be nice if that works. As long as we are fine with breaking this behaviour in the near future (to return a datetime-like with pd.NA), I am OK with converting it now.
I don't think that is a separate discussion. It is now that we have for the first time a missing value indicator that behaves differently than the others, so it is now that such questions about conversions will come up and are relevant. |
to_datetime
raises when we pass inpd.NA
but it should probably convert topd.NaT
, I think (or at least this would be better than an error)?Expected Output
The text was updated successfully, but these errors were encountered: