data_runner
data_runner

Reputation: 73

Get correlation along all rows, between two columns DF

All help is much much appreciated! Thanks

I need correlation along the rows I know how to get corr between two columns, see below.

How I get the corr along the rows in a new column? corr (11 with 84 2 with 81) etc

df['Bananas'].corr(df['Weight'])

df = pd.DataFrame({'Bananas': [11, 2, 0.5], 'Weight': [84, 81, 78]})

Upvotes: 0

Views: 153

Answers (1)

DataPlug
DataPlug

Reputation: 348

What you're looking for is df.corrwith(). This finds correlation row-wise.

Upvotes: 1

Related Questions