LoginSignup
0
0

More than 5 years have passed since last update.

DataFrameで相関係数を算出する方法

Posted at

DataFrameで相関係数を算出する方法

この記事を読むと・・・

  • 相関係数がざっくりわかる
  • DataFrameでの相関係数の算出方法がわかる

相関係数とは

  • 二つのデータの関係性の強さを-1~1の間で表す
    • 1に近いほど正の相関が強い
    • -1に近いほど負の相関が強い

df.corr()を使用して相関係数を算出

import pandas as pd

import pandas as pd

df = pd.DataFrame({
    'A':[0.9, 1, 3, 5, 6], 
    'B':[1, 10, 20, 30, 40]
})
df.corr()
  • 出力結果
       A      B
A      1 0.9779
B 0.9779      1

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0