【发布时间】:2020-02-18 12:48:15
【问题描述】:
我收到错误“ufunc 'isnan' not supported for the input types,并且无法根据强制转换规则 ''safe'' 安全地将输入强制转换为任何支持的类型。 我的数据框不包含任何 NaN,并且 dtypes 看起来不错,我什至将 index 设置为 cols 之一。
df = pd.DataFrame({ 'volume':[1.2, 0.3, 1.0, 1.8], 'team': ['A', 'B', 'C', 'D'], 'd' : ['d1', 'd2','d3', 'd4']})
df.set_index("d", inplace=True)
df.isnull().values.any()
df['volume'] = df['volume'].astype(float)
print (df.dtypes)
sns.heatmap(df, annot=True, fmt="g", cmap='viridis')
plt.show()
team object
volume float64
dtype: object
【问题讨论】: