Consider the series below:
- 100
- 102
- 101
- 103
- 0
- 12
- 123
- 14
I want the result to be as follows:
- 100
- 102
- 102
- 103
- 0
- 12
- 123
- 123
CodePudding user response:
Let d
be the variable containing your series, then groupby
the cummulative sum of d == 0
and then obtain the cummax
d.groupby(d.eq(0).cumsum()).cummax()
Out[37]:
0 100
1 102
2 102
3 103
4 0
5 12
6 123
7 123