Python Forum

Full Version: How to remove a column or two columns in a correlation heatmap?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Good morning to the community!
I would like to remove the column Dynamic (average) or Dynamic (average) and T- 10-6.
How to do this?
from pandas import read_csv
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import numpy.ma as ma
import pandas as pd

dataset = pd.read_csv('Santé3.csv', sep= ';', encoding='latin-1', index_col=0)
dataset
dataset.corr
plt.figure(figsize=(200,30))
plt.subplots(figsize=(15,8))
sns.heatmap(dataset.corr(), cmap='coolwarm', vmin=-1, vmax=1, annot=True)
Thank you in advance for your answer.
Have you tried del dataset['column'] or dataset.pop('column')?
dataset = dataset.drop(columns=['Dynamic (average)', 'T- 10-6'])
Yes, excellent your answer deanhystad and snippsat.

To eliminate just one column,

dataset = pd.read_csv('Santé3.csv', sep= ';', encoding='latin-1', index_col=0)
dataset.drop(['Dynamic (average)'], axis=1, inplace=True)
corr = dataset.corr()
mask = np.triu(np.ones_like(corr, dtype=bool))
plt.subplots(figsize=(15,8))
sns.heatmap(corr, cmap='coolwarm', vmin=-1, vmax=1, annot=True, mask=mask)