PERF: add no_nans fast path in nancorr#65046
Merged
mroeschke merged 1 commit intopandas-dev:mainfrom Apr 3, 2026
Merged
Conversation
When all values are finite, skip per-element mask checks in the inner loop of nancorr. This mirrors the existing pattern in nancorr_spearman. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mroeschke
reviewed
Apr 3, 2026
|
|
||
| result = np.empty((K, K), dtype=np.float64) | ||
| mask = np.isfinite(mat).view(np.uint8) | ||
| no_nans = np.asarray(mask).all() |
Member
There was a problem hiding this comment.
How significant is the performance improvement checking this outside the loop?
Member
Author
There was a problem hiding this comment.
I'm seeing about 7% at the top end. I also like the fact that this matches the pattern we use in nancorr_spearman
mroeschke
approved these changes
Apr 3, 2026
Member
|
Thanks @jbrockmendel |
Sharl0tteIsTaken
added a commit
to Sharl0tteIsTaken/pandas
that referenced
this pull request
Apr 4, 2026
…h-origin * upstream/main: (83 commits) PERF: minor optimizations in _libs.algos (pandas-dev#65054) TST: Add roundtrip regression test for to_csv with embedded newlines (pandas-dev#65058) DOC: fix typo in timeseries documentation (ns -> us) (pandas-dev#65070) PERF: use searchsorted in IntervalIndex.get_indexer for monotonic indexes (pandas-dev#64786) PERF : Speed up `merge(sort=False)` for range-like unique integer join keys (left/right joins) (pandas-dev#64148) BUG: exclude RangeIndex from _can_use_libjoin, fix _union sorting (pandas-dev#64797) PERF: read SAS page headers in Cython instead of Python (pandas-dev#64769) BUG: date_range with start==end and inclusive="left"/"right" returns empty (pandas-dev#65014) PERF: restore hash table pre-allocation in value_count (pandas-dev#65027) TST: Add regression test for concat with tz_convert MonthStart index (pandas-dev#65019) BUG: DatetimeIndex._is_comparable_dtype raises AttributeError on Arrow date types (pandas-dev#64953) PERF: avoid expensive DataFrame snapshot in loc.__setitem__ (pandas-dev#65028) BUG: Fix AssertionError in replace with out-of-bounds datetime (pandas-dev#65009) PERF: add no_nans fast path in nancorr (pandas-dev#65046) API/DOC: remove iterability requirement for file-like object + clarify requirements in IO docstrings (pandas-dev#64986) BUG: date_range with periods=1 raises for offsets that disallow n=0 (pandas-dev#65011) CLN: remove using_cow parameter from _iLocIndexer._align_series (pandas-dev#65036) PERF: avoid redundant category re-validation in Categorical._simple_new (pandas-dev#65042) PERF: fix O(n) linear scan in _bin_search for ObjectEngine.get_loc (pandas-dev#65016) CLN: py2 leftover comments mostly (pandas-dev#65025) ...
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.
Summary
nancorr. This mirrors the existing pattern innancorr_spearman.Test plan
pytest pandas/tests/frame/methods/test_cov_corr.py— 78 passed🤖 Generated with Claude Code