I have a Series like:
import pandas as pd
ser = pd.Series([
'the quick brown fox',
'the quick pink fox',
'a quick brown fox',
'the jumpy brown fox ',
'the quick brown animal',
])
I would like to count the number of consecutive spaces in each element. So my expected output is:
0 1
1 2
2 3
3 4
4 2
dtype: int64
because the first row contains only one consecutive space, the second one contains two consecutive spaces (between the and quick), the third row contains three consecutive spaces (between brown and fox), and so on...
I know of ser.str.count(' '), but that'll give me the total number of spaces, even if they're not consecutive