我正在使用此代码。
import pandas as pd
data = pd.DataFrame(pd.read_csv('D:\Training\TrgDS.csv', sep=',', header=None))
Xtrain = data.iloc[:,:-1]
Ytrain = data.iloc[:,-1]
start = 0
end = 9
neighbors = 8
mid = int(neighbors/2)+1
for idx, i in Xtrain.iterrows():
for j in i:
for k in range(0, 3):
sum = (
(((Xtrain.iloc[idx:idx+1,mid-1] + j - (neighbors/2))- Xtrain.iloc[idx:idx+1,mid-1])*2**k) +
(((Xtrain.iloc[idx:idx+1,mid-1] + j + 1) - Xtrain[idx:idx+1,mid-1])*2**(k+(neighbors/2)))
)
if sum < 0:
print(sum)
print('The result is 0')
else:
print(sum)
print('The result is 1')
我收到此错误:TypeError:无法散列的类型:'slice'。