question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feature request: make `scipy.stats.pearsonr` accept 2-D arrays

See original GitHub issue

I’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:open
  • Created 5 years ago
  • Comments:19 (16 by maintainers)

github_iconTop GitHub Comments

3reactions
mdhabercommented, May 4, 2022

@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?

0reactions
josef-pktcommented, May 7, 2022

(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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found