TypeError“输入类型不支持ufunc'isfinite'”

2024-10-01 15:42:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试获取csv文件中两列之间的Spearman和Kendall Tau相关性:

  • df[“信号”]包含0和1值
  • 包含浮点的df[“results”]
def Difference_No_SMA(df,stockIndex,instrument):

print("Spearman correlation : "+str(stockIndex)+" "+str(instrument))
print("\n")
print(stats.spearmanr(df['Signal'], df['results']))
print("\n")
print("Kendall Tau correlation : "+str(stockIndex)+" "+str(instrument))
print("\n")
print(stats.kendalltau(df['Signal'], df['results']))

不幸的是,执行这些代码会产生以下错误:

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

我试图编写一个循环来删除所有行,但似乎没有成功。你知道吗

你能帮帮我吗?你知道吗

致以最诚挚的问候。你知道吗


Tags: thedfsignalstatsnotresultssupportedprint

热门问题