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

PERF: RangeIndex.value_counts/searchsorted/to_numpy #58376

Merged
merged 10 commits into from Apr 29, 2024

Conversation

mroeschke
Copy link
Member

In [1]: import pandas as pd

In [2]: ri = pd.RangeIndex(100_000)

In [3]: %timeit ri.to_numpy(na_value=1)
1.29 µs ± 12.3 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)  # pr
21.2 µs ± 218 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)  # main

In [4]: %timeit ri.value_counts()
47.4 µs ± 4.41 µs per loop (mean ± std. dev. of 7 runs, 10,000 loops each)  # pr
2.75 ms ± 20.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)  # main

In [5]: %timeit ri.searchsorted(2500)
4.14 µs ± 22.4 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)  # pr
5.03 µs ± 18 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)  # main

@mroeschke mroeschke added Performance Memory or execution speed performance Index Related to the Index class or subclasses labels Apr 22, 2024
@mroeschke mroeschke added this to the 3.0 milestone Apr 22, 2024
@mroeschke
Copy link
Member Author

Going to merge, but happy to follow up if needed

@mroeschke mroeschke merged commit 3efe698 into pandas-dev:main Apr 29, 2024
46 checks passed
@mroeschke mroeschke deleted the ref/ri/methods branch April 29, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Index Related to the Index class or subclasses Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant