I have a list like this:
list_1 = [np.NaN, np.NaN, 1, np.NaN, np.NaN, np.NaN, 0, np.NaN, 1, np.NaN, 0, 1, np.NaN, 0, np.NaN, 1, np.NaN]
So the
Here's a code where a variable replace
will determine if the element should be replace or not and for
will iterate from 0
to len
of the interval and if it finds 1
then replace will true then elements will be replaced and when it will find next 0
replace will be falls and element will not replace till again appearing of 1
replace = False
for i in (len(interval)-1):
if interval[i]==1:
replace = True
elif interval[i]==0:
replace = False
if replace:
list[i]=inerval[i]