![]() |
How to remove a column or two columns in a correlation heatmap? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to remove a column or two columns in a correlation heatmap? (/thread-35118.html) |
How to remove a column or two columns in a correlation heatmap? - lulu43366 - Sep-30-2021 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. RE: How to remove a column or two columns in a correlation heatmap? - deanhystad - Sep-30-2021 Have you tried del dataset['column'] or dataset.pop('column')? RE: How to remove a column or two columns in a correlation heatmap? - snippsat - Sep-30-2021 dataset = dataset.drop(columns=['Dynamic (average)', 'T- 10-6']) RE: How to remove a column or two columns in a correlation heatmap? - lulu43366 - Sep-30-2021 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) |