the slice object “:” indicates that all the rows are selected for the given columns. Also, df2.iloc[:, [0, 1]] returns a DataFrame that has two columns and three rows. As a result, df2.iloc[:, [0, 1]].corr() will compute correlation coefficients of only column 0 and column 1 of the DataFrame.
The output of the above program will be:
DataFrame:
0 1 2 3
0 10 12 A True
1 52 61 B False
2 9 10 C True
Correlation Coefficients of column 0 and column 1:
0 1
0 1.000000 0.999898
1 0.999898 1.000000
We can interpret the correlation matrix in the same way that we discussed before.








































0 Comments