-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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: use blk.dtype
in where()
& _setitem_frame()
#61014
Merged
Merged
+6
−4
Conversation
This file contains 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
mroeschke
reviewed
Feb 27, 2025
Co-authored-by: Matthew Roeschke <[email protected]>
@mroeschke |
blk.dtype
in where()
blk.dtype
in where()
& _setitem_frame()
This pattern is also found in Lines 4276 to 4289 in 5da9eb7
BeforeAfter |
|
mroeschke
approved these changes
Feb 28, 2025
Thanks @auderson |
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.
where()
#61010 (Replace xxxx with the GitHub issue number)doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.this pr is a one-line change to the code here:
pandas/pandas/core/generic.py
Lines 9735 to 9737 in d1ec1a4
Performance comparison:
test script:
for _dt in cond.dtypes:
10 0.002963045029900968

1000 0.006705133942887187
100000 0.40306550299283117
10000000 46.55275956704281
for _dt in cond.dtypes.unique():
10 0.0028260269900783896

1000 0.002695770002901554
100000 0.042065858957357705
10000000 6.068146598991007
for _dt in [blk.dtype for blk in cond._mgr.blocks]:
10 0.0009857049444690347

1000 0.0011893719201907516
100000 0.003112988080829382
10000000 0.13763279700651765