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

Is numeric na #259

Merged
merged 2 commits into from
Jun 18, 2024
Merged

Is numeric na #259

merged 2 commits into from
Jun 18, 2024

Conversation

kmdalton
Copy link
Member

This PR speeds up dataset creation for large arrays. In working on a new stream file parser, I realized that converting numpy float32 and int32 to MTZDtypes could be very time-consuming for large arrays. After some digging, I found out the culprit was a cython function provided by pandas, pandas._libs.missing.is_numeric_na which makes a mask for missing values in rs

In the case that the input is an int32 or float32 numpy array, this is wholly unnecessary, and it is much faster to use np.isnan to accomplish the same task. This PR just wraps is_numeric_na and adds some control flow to accomplish that. It falls back to the Cython version whenever the input is not an int32 or float32 ndarray. This is a very conservative choice, and more circumstances could probably be included in the control flow down the line.

@kmdalton kmdalton requested a review from JBGreisman June 17, 2024 21:55
@kmdalton
Copy link
Member Author

This should wait to merge until after #258

Copy link
Member

@JBGreisman JBGreisman left a comment

Choose a reason for hiding this comment

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

Now that #258 is merged in, I think that some of these changes are unnecessary in this PR. Do you mind updating/rebasing so that the relevant changes aren't overwritten here?

@kmdalton
Copy link
Member Author

Okay, I cleaned up this PR. It should be good now. I will merge after the CI runs.

@kmdalton kmdalton merged commit 6c9ab8e into main Jun 18, 2024
5 checks passed
@kmdalton kmdalton deleted the is_numeric_na branch June 18, 2024 15:04
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.

2 participants