I have this dataframe
np.random.seed(0)
start_d = '2018-01-01 00:00:00'
start_d = pd.to_datetime(start_d,format='%Y-%m-%d %H:%M:%S')
end_d = '2018-01-28 00:00:00'
end_d = pd.to_datetime(end_d,format='%Y-%m-%d %H:%M:%S')
index = pd.date_range(start = start_d, end = end_d)
df = pd.DataFrame(index=index,data=np.random.randint(0,100,size=(28, 2)), columns=list('AB'))
I would like to compute the correlation between the two series but on a weekly base. In other words, I am thinking about a sort of resample with a specific apply. My idea is to apply both Pearson and Spearman. To make myself clear:
df.resample('W').corr(method='spearman)
What do you think? Is it possible to do something similar?
Best.