0

I have a matrix containing 152511 rows and 2 columns (K and A). I want to get the Spearman correlation and its p-value for every 29 rows, so I'll have 5259 correlations and p-values.

How do I operate it in Python?

medium-dimensional
  • 1,974
  • 10
  • 19
Hanifah
  • 1
  • 2
  • Welcome to SO! Can you share with us what you have tried so far? – medium-dimensional Oct 26 '22 at 07:16
  • @medium-dimensional I tried using pandas groupby but it only brings up the correlation value. Now I calculate the correlation and p-value manually every 29 rows with scipy. Is there a way to loop every 29 rows? – Hanifah Oct 26 '22 at 07:24
  • Pleas see [this answer](https://stackoverflow.com/a/55557758/7789963) on how to iterate over rows of a DataFrame with pandas. – medium-dimensional Oct 26 '22 at 07:30

0 Answers0