0
我有兩個變量,我想對它們執行元素邏輯運算。然而,我得到以下錯誤:原始熊貓數據幀的numpy數組的邏輯運算
tp = sum(actual & predicted)
TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
下面是我的代碼:
import pandas as pd
import numpy as np
train = 'train.tsv'
submission = 'submission1234.csv'
trainSearchStream = pd.read_csv(train,sep='\t')
sample = pd.read_csv(path + 'sampleSubmission.csv')
preds = np.array(pd.read_csv(submission, header = None))
index = sample.ID.values - 1
sample['IsClick'] = preds[index]
actual = np.array(trainSearchStream['IsClick'].dropna())
predicted = np.array(sample['IsClick'])
tp = sum(actual & predicted)
請發佈'actual.dtype'和'predicted.dtype'。 – unutbu
我得到float64兩個@unutbu – MAS
另外,我得到以下:打印(類型(實際)) 打印(類型(預測)) <類型 'numpy.ndarray'> <類型 'numpy.ndarray'> – MAS