How to make a correlation matrix in python

Описание к видео How to make a correlation matrix in python

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np

data = pd.read_excel("C:/Users/Karina Adcock/Documents/data analysis/samples/data.xlsx","Sheet1")

my_matrix = data.corr(method="spearman").round(2)

#my_matrix.style.background_gradient(cmap="Greens")

#pd.plotting.scatter_matrix(my_matrix, figsize=(8,8))

my_mask = np.triu(np.ones_like(my_matrix,dtype=bool))

plt.figure(figsize=(10,8)) #width, height
sns.heatmap(my_matrix, cmap="Blues", vmin=0, vmax=1,
annot=True, fmt="0.2f", square=True, mask=my_mask)

plt.show()


https://pandas.pydata.org/docs/refere...

https://r02b.github.io/seaborn_palettes/

https://seaborn.pydata.org/generated/...

Комментарии

Информация по комментариям в разработке