There is an array, that look like that (it's actually a column in a pandas dataframe, but any suggestions how to make in a plain python would also work)
[0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1, 0]
For each subsequence of 1s I need to find a midpoint position: an index of a point in the middle of this subsequence, or the closest to it. So for the example above, these would be 6 for the first subsequence, 18 for the second etc.
It can be easily done with just a naive looping, but I wonder if there is more efficient way (maybe built-in pandas function?)