My data is like this:
import numpy as np
import pandas as pd
s = pd.Series([True,True,True,False,True,False, False, True])
and I want to assign the same values(starting from 1) to the "True" rows which are adjacent to each other. And assign 0 to "False" values.
So the final result should be like this:
Here is the code I've written. I do not get any error but it cannot execute the code it seems running forever. (I don't know why!)
s['values'] = None
j = 0
for ii in range(1, len(list1)):
if list1['delay'].iloc[ii] != list1['delay'].iloc[ii-1]:
j += 1
s['values'][ii] = j
(I've started the for loop from 1 since I thought I will change the first value manually)
Please help me with this.