feature request: make `scipy.stats.pearsonr` accept 2-D arrays
See original GitHub issueI’d love to see scipy.stats.pearsonr
modified to allow 2-D arrays to be passed, with one column per variable and one row per observation. The output would be a pair of 2-D arrays–one for the Pearson correlation coefficient and one for the p-value. Currently, obtaining something like this requires a pair of nested loops, with scipy.stats.pearsonr
being called once for each pair of variables.
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (16 by maintainers)
Top Results From Across the Web
scipy.stats.pearsonr — SciPy v1.9.3 Manual
Raised if an input is a constant array. The correlation coefficient is not defined in this case, so np.nan is returned. NearConstantInputWarning.
Read more >Pearson's correlation coefficient between all pairs of rows from ...
Pearson's correlation coefficient between all pairs of rows from two 2D arrays using scipy.stats.pearsonr vs. numpy.corrcoeff in python 3.5.
Read more >Compute cross-correlation (similar to pd.Series.corr ... - GitHub
The first step here is to find a library that implements the desired functionality on pure NumPy arrays, ideally in a vectorized fashion....
Read more >SciPy 1.8.0 Release Notes
x branch, and on adding new features on the master branch. This release requires Python 3.8+ and NumPy 1.17.3 or greater. For running...
Read more >SciPy 1.0: fundamental algorithms for scientific computing in ...
This remains a distinguishing feature of Python for science and one of the reasons why it has been so successful in the realm...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tirthasheshpatel @tupui @Kai-Striega what do you think? Shall we get the deprecation in before 1.9.0 branches so we can vectorize these consistently?
(after another break)
I would put sommersd in a similar category as the correlations measures for ordinal association. One possible multivariate extension would be to return an asymmetric association matrix with sommersd(x, y) in the upper (?) triangular matrix and sommersd(y, x) in the lower triangular matrix.
But that’s purely theoretical, I’ve never seen a usecase like that. And I don’t know if there are interesting followup analyses that would use it.