I have a csv file like this:
date,sym,close
2014.01.01,A,10
2014.01.02,A,11
2014.01.03,A,12
2014.01.04,A,13
2014.01.01,B,20
2014.01.02,B,22
2014.01.03,B,23
2014.01.01,C,33
2014.01.02,C,32
2014.01.03,C,31
Then, I get a dateframe named df
via read_csv
function
import numpy as np
import pandas as pd
df=pd.read_csv('daily.csv',index_col=[0])
groups=df.groupby('sym')[['close']].apply(lambda x:func(x['close'].values))
The groups
look like this:
sym
A [nan,1.00,2.00,...]
B [nan,1.00,2.00,...]
C [nan,1.00,2.00,...]
How to calculate the correlation between each pair of sym?
AA,AB,AC,BB,BA,BC,CA,CB,CC
BTW, the item numbers of each sym may be NOT the same.