PERF: DataFrame.transpose for pyarrow-backed#54224
Merged
mroeschke merged 6 commits intopandas-dev:mainfrom Jul 24, 2023
Merged
PERF: DataFrame.transpose for pyarrow-backed#54224mroeschke merged 6 commits intopandas-dev:mainfrom
mroeschke merged 6 commits intopandas-dev:mainfrom
Conversation
pandas/core/frame.py
Outdated
| if isinstance(self._mgr, ArrayManager): | ||
| arrays = self._mgr.arrays | ||
| else: | ||
| arrays = list(self._iter_column_arrays()) |
Member
There was a problem hiding this comment.
cant do this unconditionally?
Member
Author
There was a problem hiding this comment.
Do you mean use _iter_column_arrays in both cases? The masked array implementation just above this uses the condition as well, presumably for performance:
import pandas as pd
pd.options.mode.data_manager = "array"
df = pd.DataFrame(columns=range(100000), dtype="int64[pyarrow]")
%timeit list(df._iter_column_arrays())
# 57.9 ms ± 2.7 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
%timeit df._mgr.arrays
# 110 ns ± 8.79 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
Member
There was a problem hiding this comment.
Fair enough, thanks for taking a look
Member
Author
There was a problem hiding this comment.
on second thought, I moved the condition into DataFrame._iter_column_arrays to avoid repeating it elsewhere
mroeschke
approved these changes
Jul 24, 2023
Member
|
Thanks @lukemanley |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
doc/source/whatsnew/v2.1.0.rstfile if fixing a bug or adding a new feature.Similar to #52836, but for pyarrow-backed frames.
Renamed the masked implementation from
homogenous->homogeneous. Both may be valid(?), buthomogeneousis used elsewhere.