-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
ENH: Infer dtype from non-nulls when pushing to SQL #8973
Conversation
4262ab6
to
b8537c0
Compare
can u show what u r passing that raises on Categorical |
Yes, here's the snippet. Interestingly, it works for a dataframe but not for a series.
|
that's not really valid input, it has to be an ndarray (though we have relaxed it a bit). But I will add this as it should be able to infer (its easy to do), it just checks the dtype (and doesn't do anything more) |
b8537c0
to
7072f3d
Compare
@jreback Great, thanks! Simplified this PR a bit (no longer doing special check for categorical type) |
@@ -884,37 +884,49 @@ def _harmonize_columns(self, parse_dates=None): | |||
except KeyError: | |||
pass # this column not in results | |||
|
|||
def _get_notnull_col_dtype(self, col): | |||
col_for_inference = col |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a docstring to explain why this is needed?
@artemyk put some comments, but in general it looks very good! |
@jorisvandenbossche Thanks, made the fixes. Regarding And yes, I removed the previous testing for dtype, lines like |
@jorisvandenbossche Oh, that makes sense! Added check / test for complex numbers . |
@jorisvandenbosscher ready to go? |
yep, looking good! @artemyk can you add a release note and squash? |
ee4f172
to
944b28b
Compare
looks ok to me, any docs need to be updated for this? (maybe a note somewhere explaining what this is doing), e.g. maybe add a 'dtypes' sub-section for SQL (as getting more traction in this area). Could be done in separate issue. |
@artemyk hmm, can you rebase again? Docs can go in a seperate PR I think (more general than this) |
@jreback did a PR for your doc suggestion |
Minor cleanup Minor rename Simplifying Code review fixes Complex numbers Release note Release note
944b28b
to
ffc5097
Compare
@jorisvandenbossche Rebased on master, let me if I still need to fix something. And thanks for doing the docs! |
ENH: Infer dtype from non-nulls when pushing to SQL
@artemyk Thanks a lot! |
Closes #8778
This infers dtype from non-null values for insertion into SQL database. See #8778 . I had to alter @tiagoantao test a bit.
Like @tiagoantao, I skipped writing tests for legacy MySQL. Support for this will be removed soon, right?
As a side note,
lib.infer_dtype
throws an exception for categorical data -- probably shouldn't happen, right?@jorisvandenbossche
@jahfet
@tiagoantao