I have a pandas dataframe and i am trying to count the number of zeros before every digit till a non zero number shows up and capture it into the next column. How can I do this using pandas?
This is how the output needs to be in zeroCumulative
column. For example, number of zeros before 101
is 0
, number of zeros before 73
is 3
and so on. Number of zeros before any zero also needs to be counted.
value zeroCumulative
70
127 0
101 0
0 0
0 1
0 2
73 3
0 0
55 1
0 0
Thanks in advance!