在计算LBP值时,遇到错误emssage TypeError:无法散列的类型:'sl​​ice'

时间:2020-05-11 06:54:07

标签: pandas dataframe slice

我在csv文件中有180列和41080行的数据集。 enter image description here

我正在使用“本地二进制模式”的公式来计算值。 enter image description here

我正在使用此代码。

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:无法散列的类型:'sl​​ice'。

0 个答案:

没有答案