Python Seaborn热图

时间:2019-01-07 18:27:01

标签: python pandas seaborn

我正尝试使用以下数据集重新创建以下热图:

https://seaborn.pydata.org/examples/heatmap_annotation.html

我遇到以下错误:

calc_data = plot_data.data [〜np.isnan(plot_data.data)] TypeError:输入类型不支持ufunc'isnan',

任何帮助解决该问题的方法将不胜感激。数据似乎可以正确加载和旋转,但可能不是正确的dtype。

谢谢

蒂姆

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

sns.set()

# Load the example flights dataset and convert to long-form

flights_long = pd.read_csv("Data.csv")

flights = flights_long.pivot("month", "year", "passengers")


# Draw a heatmap with the numeric values in each cell

f, ax = plt.subplots(figsize=(9, 6))
sns.heatmap(flights, annot=True, fmt="d", linewidths=.5, ax=ax)
plt.show()

0 个答案:

没有答案
相关问题