Q:

Count of values between other values in a pandas DataFrame

I have a column of a pandas DataFrame that looks like this:
1       False
2       False
3       False
4        True
5        True
6       False
7       False
8       False
9       False
10      False
11      True
12      False

I would like to get the count of False between the True.  Something like this:
1      3
2      0
3      5
4      1

This is what I've done:
counts = []
count = 0
for k in df['result'].index:
    if df['result'].loc[k] == False:
        count += 1
    else:
        counts.append(count)
        count = 0

where counts would be the result.  Is there a simpler way? 

A:

Group by the cumulative sum of itself and then count the False with sum:
s = pd. Series([False, False, False,  True,  True, False, False, False, False, False,  True, False])

(~s).groupby(s.cumsum()).sum()
#0    3.0
#1    0.0
#2    5.0
#3    1.0
#dtype: float64

