I am trying to get the Spearman and the Kendall Tau correlation between two columns in a csv file :

  • df["signal"] that contains 0 and 1 value
  • df["results"] that contains float
def Difference_No_SMA(df,stockIndex,instrument):

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

Unfortunately the execution of this codes give the following error :

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''

I tried to code a loop to remove all the row but it seems that I am not successful.

Could you please help me?

Best regards.

0 Answers