import pandas as pd
import numpy as np
np.random.seed([3, 1415])
n = 100
df = pd.DataFrame(
np.random.rand(n, 4),
pd.date_range('2000-01-01', periods=n, name='date'),
['ABC','XYZ __', 'One', 'Two Three']
)
def dcorr(df, n):
return df.resample(f"{n}D").apply(lambda d: d.corr())
dcorr(df, 20)