python - python seaborn 热图
问题描述
我正在尝试使用我自己的数据集从以下内容重新创建以下热图:
https://seaborn.pydata.org/examples/heatmap_annotation.html
我收到以下错误:
calc_data = plot_data.data[~np.isnan(plot_data.data)] TypeError: ufunc 'isnan' not supported for the input types, a
任何帮助解决它将不胜感激。数据似乎可以正确加载和旋转,但可能不是正确的 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()
解决方案
推荐阅读
- if-statement - Netlogo:通过调整其他行/列来替换矩阵元素
- git - 当强制推送到远程 git 存储库时,现有标签会发生什么情况?
- php - 使用 hasMany 关系数据加载 Laravel 模型
- php - 通过表单更改为另一个 PHP 文件包含的 HTML
- python - Django如何读取应用程序子目录文件夹中的文件?
- c++ - 复制一个对象并使两者共享一个成员变量(C++)
- android - 即使在 .bringToFront 和 View.VISIBLE 之后,DrawerLayout 上方的视图也不会变得可见
- javascript - 动态表单组件 markAsDirty() 错误:ExpressionChangedAfterItHasBeenCheckedError
- c - Ruby/FFI:字符串未到达 *char 函数参数
- javascript - 如何使用 for 循环在 javascript 中编写和调用函数?