-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
problem with to_sql with NA #8778
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
I think this would be a reasonable addition to the api (a |
comment from @artemyk in #8926:
I think the problem with that is that the series can also be really mixed (and not only because of the nan's), and then the checking on one scalar can give wrong results.
|
@jorisvandenbossche Yes, I think that would be very useful (though perhaps the real solution would be to have typed NA values --- I suppose that would require some big structural changes though). I can see how having the |
@jorisvandenbossche I looked into how
Not sure how slow this would be for large dataframes. |
The |
Hmm, this seems certainly like something that can be added to the type interference just before the last step when for object |
@jorisvandenbossche yep, much better. In fact the only series you really need to infer is a mixed-type boolean I think. (e.g. if its object, then infer it; check if its mixed, then remove nans and reinfer). |
@jorisvandenbossche Oh, nice! Didn't realize that |
A little weird though since |
@artemyk these are 'specific' to pandas and not real 'types'. These are to try to figure out things when given unknown input. These are purely internal. |
Going to keep this open for now, given the discussion above |
@artemyk @jorisvandenbossche @jreback Thanks a lot all, I just upgraded to 0.15.2 and can confirm that I can now successfully round trip data from / to sql following this bug fix. Due to the second PR I don't even need to use the specific dtypes parameter in my test case! |
i am experiencing issues with writing NA values for a column of boolean with missing values.
I am reading data from a mssql server and am trying to write it unchanged in another table.
As the data contains NULL values, pandas changes the dtype to object. when calling to_sql, object fields seem to be mapped to a "text" column type, and the export then fails:
'object' dtypes are tricky to handle systematically I guess, but maybe we could add the ability to tell pandas how to handle it on a column by column basis?.
something like:
could do the trick?
The text was updated successfully, but these errors were encountered: