0

I am using pingouin stat package to find the correlation between two sets of data, and I then want to check if this correlation is strong. However, I get 5-6 output values, of which only one is r. How do I obtain the r out of the output data?

Code:

b = pg.corr(x=df['Bitcoin Start Value'], y=df['Gold Start Value'])

Output:

          n      r         CI95%     r2  adj_r2     p-val    BF10  power
pearson  35  0.558  [0.28, 0.75]  0.311   0.268  0.000501  70.273   0.95
Wolf
  • 9,679
  • 7
  • 62
  • 108
Earlybird
  • 31
  • 1
  • 3
  • 1
    According to https://pingouin-stats.org/generated/pingouin.corr.html the `pingouin.corr` function returns a `pandas DataFrame`. According to https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html you can access elements of such a data frame with the `.at` function, so you should try something like `b.at("pearson", "r")`.Make sure to just check the documentations recursively in such cases. – Miiller Nov 28 '19 at 10:54
  • Does this answer your question? [Extract a single value from a pandas dataframe](https://stackoverflow.com/questions/56187039/extract-a-single-value-from-a-pandas-dataframe) – Wolf May 31 '21 at 11:34

1 Answers1

-1

Writing b['r'][0] will give you the r number. The same with the other output variables.

Cristian Ispan
  • 571
  • 2
  • 5
  • 23
  • Sorry my typo (removing `b`) was not intentional. I don't know who voted this down, but the reason might be that there is no indication *why* your solution works, which it of course does. So maybe adding a reference could help that explains the data structure. See above comment by Miiller. – Wolf May 31 '21 at 11:44