Skip to content
C

Problem 2: Identify Features Most Correlated with the Target

Easypython

Problem Description

Write a Python program that computes the correlation of all features with a target column ("price"), and prints them sorted from highest to lowest correlation.

Input

A DataFrame with several numeric feature columns and one target column.

Output

A sorted list of correlations with the target.

Constraints

  • The target column must be named "price".

Example Input

text
{"size": [1000,1500,2000], "rooms": [2,3,4], "price": [200000,280000,350000]}

Example Output

text
price 1.000000 size 0.998... rooms 0.995...

Concepts Covered

df.corr(), sort_values().

Input (stdin)

Output

Run your code to see output here...