0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ああああ

Posted at

import pandas as pd

dfmt_2 と dfmt_3 のデータフレームを読み込む想定です。

ここで具体的な読み込み方は省略しますが、通常は pd.read_csv や pd.read_excel を使います。

データフレームが TDATE と分位 (qua1~qua5) でインデックスされている場合、

マージする前にリセットして普通のカラムに戻します。

dfmt_2_reset = dfmt_2.reset_index()
dfmt_3_reset = dfmt_3.reset_index()

TDATE と分位でマージします。

merged_df = pd.merge(dfmt_2_reset, dfmt_3_reset, on=['TDATE', '分位'], suffixes=('_2', '_3'))

Excess_Return の列で相関係数を計算します。

correlation = merged_df['Excess_Return_2'].corr(merged_df['Excess_Return_3'])

print(f'相関係数: {correlation}')

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?