How do I calculate correlation in python Only the first 9 columns and the iloc function are to be used corr_matrix = dataset.iloc[:,0:8].corr()

Question:

What should go in the corr () argument?
The idea is to used column parameters from 0 to 8 to find correlation

corr_matrix = dataset.iloc[:,0:8].corr()

The problem is using iloc with corr

Asked By: Nafiisa

||

Answers:

Does the following work for you?:

subset = dataset[["col1_name","col2_name", ..., "col8name"]] 
corr_matrix = subset.corr()
Answered By: jjislam
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.