I have a column in a dataframe which is filled with booleans and i want to count how many times it changes from True to False.
I can do this when I convert the booleans to 1's and 0's ,then use df.diff
and then divide that answer by 2
import pandas as pd
d = {'Col1': [True, True, True, False, False, False, True, True, True, True, False, False, False, True, True, False, False, True, ]}
df = pd.DataFrame(data=d)
print(df)
0 True
1 True
2 True
3 False
4 False
5 False
6 True
7 True
8 True
9 True
10 False
11 False
12 False
13 True
14 True
15 False
16 False
My expected outcome would be
The amount of times False came up is 3