Skip to content
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

fix: Pandas parser does fail to parse integer or boolean only dataframes #1683

Merged
merged 4 commits into from
Sep 16, 2024

Conversation

pierrecamilleri
Copy link
Collaborator

@pierrecamilleri pierrecamilleri commented Sep 13, 2024

Converting the Series returned by iterrows() to a dict converts np.int64 type to python's native int type and fixes the bug (same with booleans).

  • Adding non-regression tests
  • I was also concerned with the next lines, especially : if value is np.nan: value = None
    • it was untested, so I added a test. It looks like to_dict would not change the behavior of np.nan conversion (see side note), so I left this code unchanged.
  • Primary keys are returned as ints or tuple[int], no np.int64 there
  • Timestamps types are kept unchanged, so the if isinstance(value, pd.Timestamp): still applies.

Side note

np.nan behavior is quite strange with df.iterrows() : in a number column, it will be converted to float("nan"), whereas in string column it will be kept as np.nan. Adding to_dict() to the row Series does not change the types.

@pierrecamilleri
Copy link
Collaborator Author

@roll @pdelboca ready for review !

Copy link
Contributor

@pdelboca pdelboca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I like changes followed by tests 👍🏼

@pierrecamilleri pierrecamilleri merged commit 0e60e0b into main Sep 16, 2024
9 checks passed
@pierrecamilleri pierrecamilleri deleted the fix/1678-pandas-parser-bug branch September 16, 2024 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reading data from pandas returns null values
2 participants