-
Notifications
You must be signed in to change notification settings - Fork 48
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
if_else shouldn't coerce nan to strings #179
Comments
I think the solution to this problem is to replace the very last line... return np.array(list(result)) with return pd.Series(result) There are two reasons...
Alternatively, we could engage whatever mechanism pandas uses for converting the final array, since we don't really need all the Series machinery (e.g. an index). However, I suspect as pandas supports String arrays, etc.., through Series, it will become harder to avoid them. |
Instead of fix 2 (returning a Series), I opted to just keep the np array dtype "O". The reasoning is..
(this is why pandas goes to great lengths to wait to convert types, until the very end of a set of operations) |
Edit: Removed pasted code snipper, replaced with reproducible example.
Problem:
if_else
can end up convertingnp.nan
to a string: "nan".Cause:
if_else
tries to downcast using numpy at the very endExample
The root cause in is the method used to downcast at the end. Here is the problem shown just with numpy...
The text was updated successfully, but these errors were encountered: