Python ';无法将[%s]与块值进行比较';for循环中的错误

Python ';无法将[%s]与块值进行比较';for循环中的错误,python,pandas,dataframe,for-loop,Python,Pandas,Dataframe,For Loop,在for循环中使用此过滤方法有一个问题。我有一个4个不同数据帧的列表,我想检查4列,并检查其中是否有特定的字符串,其中files是数据帧的列表: filtered = [] for ii in range(len(files)): nsigma = files[ii][files[ii][['phase_1','phase_2','phase_3','phase_4']].ne('SIGMA#1').all(1)] filtered.append(nsigma) #I get '

在for循环中使用此过滤方法有一个问题。我有一个4个不同数据帧的列表,我想检查4列,并检查其中是否有特定的字符串,其中files是数据帧的列表:

filtered = []
for ii in range(len(files)):
    nsigma = files[ii][files[ii][['phase_1','phase_2','phase_3','phase_4']].ne('SIGMA#1').all(1)]
    filtered.append(nsigma)
#I get 'Could not compare ['SIGMA#1'] with block values' error with this

#however, this next line works perfectly fine and does not give me an error

 nsigma = files[0][files[0][['phase_1','phase_2','phase_3','phase_4']].ne('SIGMA#1').all(1)]
我不知道为什么for循环会把事情搞砸。。。 感谢所有回答这个问题的人


更新:现在所有的数据帧都不起作用了,我不确定我是怎么调整的。是否每个数据帧都会出现错误?当它断开时,
ii
的值是多少?