Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas plot heatmap

import matplotlib.pyplot as plt
import seaborn as sns

# optional: resize images from now on
plt.rcParams["figure.figsize"] = (16, 12)

# numeric_only_columns is a list of columns of the DataFrame
# containing numerical data only
# annot = True to visualize the correlation factor

sns.heatmap(df[numeric_only_columns].corr(), annot = False)
plt.show()
Comment

heatmap of pandas dataframe with seaborn

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

# create some random data; replace that by your actual dataset
data = pd.DataFrame(np.random.rand(11, 5), columns=['A', 'B', 'C', 'D', 'E'], index = range(2000, 2011, 1))

# plot heatmap
ax = sns.heatmap(data.T)

# turn the axis label
for item in ax.get_yticklabels():
    item.set_rotation(0)

for item in ax.get_xticklabels():
    item.set_rotation(90)

# save figure
plt.savefig('seabornPandas.png', dpi=100)
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: how to create an empty 2d list in python 
Python :: python pip fix 
Python :: making hexagon in python turtle 
Python :: how to extract zip file in jupyter notebook 
Python :: python convert base 
Python :: matplotlib remove y axis label 
Python :: python saveAsTextFile 
Python :: generate valid sudoku board python 
Python :: do you have to qualift for mosp twice? 
Python :: pandas diff between dates 
Python :: openpyxl delete rows 
Python :: order dataframe by multiple columns python 
Python :: normalise min max all columns pandas 
Python :: ax set xtick size 
Python :: read bytes from file python 
Python :: how to add card in py-trello 
Python :: logout in discord.py 
Python :: filter an importrange 
Python :: clear pygame screen 
Python :: django datetimefield default 
Python :: Goal Parser Python 
Python :: save plot as image python matplotlib 
Python :: convert files from jpg to png and save in a new directory python 
Python :: previous value list loop python 
Python :: pandas dataframe get number of columns 
Python :: char list 
Python :: how to clean a mask cv2 in python 
Python :: python how to sort by date 
Python :: show all rows with nan for a column value pandas 
Python :: how to make a never ending loop in python 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =