SNIPPET
3 Upvotes

Sorted Absolute Correlation Table

Python
Visualisation & EDA

Display the correlation and absolute column values between the numerical columns in the DataFrame and the 'target' column.

def correlation_table(data,target_column):
	data_num = data.select_dtypes(include=['int','float'])
	corr_df = pd.DataFrame(data_num.corrwith(data_num[target_column]),columns=['Correlation']).dropna()
	corr_df['ABS Correlation'] = abs(corr_df['Correlation'])
	corr_df.sort_values(by=['ABS Correlation'], ascending=False, inplace=True)
	print(corr_df)

correlation_table(df, 'target')
{{ snippet.title}

By analyseup - Last Updated Sept. 17, 2021, 2:14 p.m.

COMMENTS
RELATED SNIPPETS
2
Search Snippets by Tag: