one = pd.DataFrame(data=[1,2,3,4,5], index=[1,2,3,4,5])
two = pd.DataFrame(data=[5,4,3,2,1], index=[1,2,3,4,5])
one.corr(two)
I think it should return a float = -1.00 but instead it's generating the following error:
TypeError: Could not compare ['pearson'] with block values
Thanks in advance for your help.
pandas.DataFrame.corr
computes pairwise correlation between the columns of a single data frame. What you need here is pandas.DataFrame.corrwith
:
>>> one.corrwith(two)
0 -1
dtype: float64