我正在尝试检查数据框中 B-B-B 的顺序。
d = {'A': ['A','B','C','D','B','B','B','A','A','E','F','B','B','B','F','A','A']}
testdf = pd.DataFrame(data=d)
array = []
seq = pd.Series(['B', 'B', 'B'])
for i in testdf.index:
if testdf.A[i:len(seq)] == seq:
array.append(testdf.A[i:len(seq)+1])
我收到错误:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
我怎样才能让它工作?我不明白这段代码有什么“不明确”之处
我想要的输出是:
A, F