Skip to content

PERF: RangeIndex.value_counts/searchsorted/to_numpy #58376

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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
@mroeschke mroeschke deleted the ref/ri/methods branch April 29, 2024 18:01
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
* Add RangeIndex.value_counts,searchsorted,to_numpy

* Undo engine stuff

* Finish searchsorted, add wahtsnew

* Remove old to_numpy implementation

* Add whatsnew for to_numpy

* add whatsnew number

* Fix typing
# for free to join this conversation on GitHub. Already have an account? # 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.

1 participant