I have the following data frame:
vote_prprtn uniform_votesh p_by_q ln_p_by_q p_ln_p_by_q match
0.0116 0.009367 1.238434 0.213848 0.002481 False
0.0100 0.009367 1.067616 0.065428 0.000654 True
0.0065 0.009367 0.693950 -0.365355 -0.002375 True
0.0072 0.006000 1.200000 0.182321 0.001313 False
0.0048 0.006000 0.800000 -0.223143 -0.001071 True
I want to create another column which has the row value of p_ln_p_by_q when match = False and does a cumulative sum, row by row when match is True. This continues until the next False value. My final dataframe should look like this:
vote_prprtn uniform_votesh p_by_q ln_p_by_q p_ln_p_by_q match final_val
0.0116 0.009367 1.238434 0.213848 0.002481 False 0.002481
0.0100 0.009367 1.067616 0.065428 0.000654 True 0.003135
0.0065 0.009367 0.693950 -0.365355 -0.002375 True 0.00076
0.0072 0.006000 1.200000 0.182321 0.001313 False 0.001313
0.0048 0.006000 0.800000 -0.223143 -0.001071 True 0.000242
Any help on this would genuinely make me understand the parallels between excel and pandas.