Python Forum
How to remove a column or two columns in a correlation heatmap?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to remove a column or two columns in a correlation heatmap?
#1
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.

Attached Files

Thumbnail(s)
   

.csv   Santé3.csv (Size: 4.45 KB / Downloads: 217)
Reply
#2
Have you tried del dataset['column'] or dataset.pop('column')?
Reply
#3
dataset = dataset.drop(columns=['Dynamic (average)', 'T- 10-6'])
lulu43366 likes this post
Reply
#4
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)

Attached Files

Thumbnail(s)
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting column of values into muliple columns of counts highland44 0 254 Feb-01-2024, 12:48 AM
Last Post: highland44
  Remove some columns James_S 4 804 Dec-16-2023, 11:02 PM
Last Post: James_S
  I am getting a valueError. And not sure why? My goal is to visualize the correlation ReadytoCode 0 473 Dec-11-2023, 05:33 AM
Last Post: ReadytoCode
  How to plot seaborn heatmap on top of a background circle SriRajesh 0 1,417 Jul-09-2022, 04:00 AM
Last Post: SriRajesh
  df column aggregate and group by multiple columns SriRajesh 0 1,043 May-06-2022, 02:26 PM
Last Post: SriRajesh
  Transform 3 Columns into Single Column DaveG 8 1,875 Apr-04-2022, 08:42 AM
Last Post: Pedroski55
  Error in find pearson correlation function erneelgupta 1 1,869 Mar-01-2022, 03:41 PM
Last Post: stevendaprano
  Remove if similar values available based on two columns klllmmm 1 1,363 Feb-20-2022, 06:55 PM
Last Post: Larz60+
  Split single column to multiple columns SriRajesh 1 1,330 Jan-07-2022, 06:43 PM
Last Post: jefsummers
  How to increase the size of a png picture for the heatmap of the correlation? lulu43366 9 3,511 Oct-06-2021, 04:15 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020