如何为Year
,State
和Engine
的颜色制作热图?
Year Make Engine State Tally
2012 Acura 2.4 Rhode Island 1
2013 Acura 3.5 Rhode Island 1
2012 Acura 1.8 Rhode Island 1
2013 Acura 2.4 Rhode Island 1
2015 Acura 2.4 Rhode Island 1
2016 Acura 2.4 Rhode Island 1
2015 Acura 3 Rhode Island 1
2017 Acura 1.8 Rhode Island 1
答案 0 :(得分:0)
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
heatmapdata = pd.pivot_table(df, values='Engine', index=['State'], columns='Year')
sns.heatmap(heatmapdata, cmap="YlOrRd")
df是数据框的名称。