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 :: numpy 3 dimensional array 
Python :: 3d array numpy 
Python :: how to get scrapy output file in csv 
Python :: pandas dataframe add column from another column 
Python :: first and last digit codechef solution 
Python :: python mode 
Python :: np where nan 
Python :: python diagonal sum 
Python :: how to use h5 file in python 
Python :: python lambda 
Python :: random split train test in python 
Python :: input numpy array 
Python :: python datetime format string 
Python :: convert rgb to a single value 
Python :: django create object with default today date 
Python :: append dictionary to list python 
Python :: git help 
Python :: sorting tuples 
Python :: numpy remove columns containing nan 
Python :: zero crossing rate python 
Python :: how to give bar plot groupby python different colors 
Python :: most frequent word in an array of strings python 
Python :: how to get confusion matrix in python 
Python :: python create a pinging sound 
Python :: tuple plot python 
Python :: python youtube download mp3 
Python :: progress bar python 
Python :: django queryset group by 
Python :: delete a column in pandas 
Python :: Python program to print even numbers in a list 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =