Reputation: 41
Is it possible to do a correlation between multiple columns against one column in pandas? Like:
DF[['A']['B']].corr(DF['C'])
Upvotes: 4
Views: 5561
Reputation: 862406
I believe you need corrwith and select multiple columns by list:
corrwith
list
DF = pd.DataFrame({ 'B':[4,5,4,5,5,4], 'C':[7,8,9,4,2,3], 'A':[1,3,5,7,1,0], }) print (DF[['A', 'B']].corrwith(DF['C'])) A 0.319717 B -0.316862 dtype: float64
Upvotes: 3