I have a pandas dataframe that has multiple columns, of which I am interested in a specific column that has a series of (1, or 0). The logic that I want to perform is:
If (the current row is 1 and the next row is 0):
    count = count + 1
else :
    pass
df['NewCol'] = count
so, this is what I tried:
secCnt = 0 
def sectionCount(data):
    global secCnt
    if( (data[['secFlg']] == 0) and (data[['secFlg'].shift(-1)] == 1) ):
        secCnt = secCnt + 1 
    else:
        pass
    return secCnt
if __name__ == "__main__":
    df['SectionIndex'] = df.apply(sectionCount(df), axis=1)
I get the error:
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
pI am new to pandas and am performing text extraction from a pdf file and am interested in finding out sections in the pdf file
 
     
    