Skip to content

PERF: Series.str.get for pyarrow-backed strings #53152

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 5 commits into from
May 10, 2023

Conversation

lukemanley
Copy link
Member

import pandas as pd
import pandas._testing as tm
import pyarrow as pa

N = 1_000_000

ser = pd.Series(tm.makeStringIndex(N), dtype=pd.ArrowDtype(pa.string()))

%timeit ser.str.get(1)

# 70.1 ms ± 3.13 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)  -> main
# 37.7 ms ± 2.09 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)  -> PR

@lukemanley lukemanley added Performance Memory or execution speed performance Arrow pyarrow functionality labels May 9, 2023
@mroeschke
Copy link
Member

sort whatsnew entries alphabetically....................................................................Failed
- hook id: sort-whatsnew-items
- duration: 0.04s
- exit code: 1
- files were modified by this hook
pre-commit hook(s) made changes.
If you are seeing this message in CI, reproduce locally with: `pre-commit run --all-files`.
To run `pre-commit` as part of git workflow, use `pre-commit install`.
All changes made by hooks:
diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst
index 44ba2ac..a7ad001 100644
--- a/doc/source/whatsnew/v2.1.0.rst
+++ b/doc/source/whatsnew/v2.1.0.rst
@@ -290,10 +290,10 @@ Performance improvements
 - Performance improvement in :meth:`.DataFrameGroupBy.groups` (:issue:`53088`)
 - Performance improvement in :meth:`DataFrame.loc` when selecting rows and columns (:issue:`53014`)
 - Performance improvement in :meth:`Series.corr` and :meth:`Series.cov` for extension dtypes (:issue:`52502`)
+- Performance improvement in :meth:`Series.str.get` for pyarrow-backed strings (:issue:`53152`)
 - Performance improvement in :meth:`Series.to_numpy` when dtype is a numpy float dtype and ``na_value`` is ``np.nan`` (:issue:`52430`)
 - Performance improvement in :meth:`~arrays.ArrowExtensionArray.to_numpy` (:issue:`52525`)
 - Performance improvement when doing various reshaping operations on :class:`arrays.IntegerArrays` & :class:`arrays.FloatingArray` by avoiding doing unnecessary validation (:issue:`53013`)
-- Performance improvement in :meth:`Series.str.get` for pyarrow-backed strings (:issue:`53152`)
 -

@mroeschke mroeschke added this to the 2.1 milestone May 10, 2023
@mroeschke mroeschke merged commit a90fbc8 into pandas-dev:main May 10, 2023
@mroeschke
Copy link
Member

Thanks @lukemanley

Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
* PERF: Series.str.get for pyarrow-backed strings

* whatsnew

* whatsnew

* whatsnew
@lukemanley lukemanley deleted the perf-arrow-str-get branch May 30, 2023 22:16
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
* PERF: Series.str.get for pyarrow-backed strings

* whatsnew

* whatsnew

* whatsnew
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