Skip to content

PERF: Improve performance for pyarrow to_numpy with na and na_value #51439

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

Merged
merged 6 commits into from
Feb 17, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Feb 16, 2023

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

saw this in the engine pr, avoids a warning and improves performance:

pr
%timeit ser.to_numpy(dtype="int64", na_value=1.5)
1.67 ms ± 11.2 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)

main
%timeit ser.to_numpy(dtype="int64", na_value=1.5)
/Users/patrick/PycharmProjects/pandas/pandas/core/arrays/arrow/array.py:893: RuntimeWarning: invalid value encountered in cast
  result = np.asarray(self._data, dtype=dtype)
2.42 ms ± 30.3 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

@mroeschke mroeschke added Performance Memory or execution speed performance Arrow pyarrow functionality labels Feb 16, 2023
@mroeschke mroeschke added this to the 2.0 milestone Feb 16, 2023
@phofl
Copy link
Member Author

phofl commented Feb 17, 2023

greenish

@phofl phofl merged commit 78cf4d7 into pandas-dev:main Feb 17, 2023
@phofl phofl deleted the to_numpy_pyarrow branch February 17, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants