I'm trying to check for the sequence of B-B-B in the dataframe.
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])
I get an error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
How can I get it working? I don't understand what's "ambiguous" about this code
My desired output here is:
A, F