Home > Net >  Add to the list, a value of a column of the current row of a DataFrame only if the previous rows pas
Add to the list, a value of a column of the current row of a DataFrame only if the previous rows pas

Time:12-05

A brief example of my CSV file (there is no way to publish complete by the limit of characters):

market_name,runner_name,odds,result,back
First Half Goals 0.5,Over 0.5 Goals,1.7,WINNER,0.6545
Over/Under 6.5 Goals,Under 6.5 Goals,1.01,WINNER,0.00935
Over/Under 0.5 Goals,Over 0.5 Goals,1.71,WINNER,0.66385
Over/Under 2.5 Goals,Under 2.5 Goals,1.41,WINNER,0.3833499999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.25,WINNER,0.23375
Over/Under 4.5 Goals,Under 4.5 Goals,1.34,WINNER,0.3179
First Half Goals 0.5,Under 0.5 Goals,1.96,WINNER,0.8976000000000001
Over/Under 1.5 Goals,Over 1.5 Goals,1.6,WINNER,0.5610000000000002
Over/Under 2.5 Goals,Over 2.5 Goals,1.21,WINNER,0.1963499999999999
Over/Under 3.5 Goals,Over 3.5 Goals,1.18,WINNER,0.1682999999999999
Over/Under 3.5 Goals,Under 3.5 Goals,1.98,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.09,WINNER,0.08415
Over/Under 3.5 Goals,Over 3.5 Goals,2.02,LOSER,-1.0
Over/Under 1.5 Goals,Under 1.5 Goals,3.15,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.44,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.7,WINNER,0.6545
Over/Under 1.5 Goals,Over 1.5 Goals,1.24,WINNER,0.2244
Over/Under 4.5 Goals,Over 4.5 Goals,2.06,WINNER,0.9911
Over/Under 3.5 Goals,Under 3.5 Goals,2.0,WINNER,0.935
Over/Under 1.5 Goals,Under 1.5 Goals,1.41,WINNER,0.3833499999999999
Over/Under 7.5 Goals,Under 7.5 Goals,1.27,WINNER,0.25245
Over/Under 5.5 Goals,Under 5.5 Goals,1.5,WINNER,0.4675
Over/Under 4.5 Goals,Under 4.5 Goals,1.29,WINNER,0.27115
Over/Under 1.5 Goals,Over 1.5 Goals,1.15,WINNER,0.1402499999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.53,WINNER,0.49555
Over/Under 1.5 Goals,Over 1.5 Goals,1.57,WINNER,0.53295
First Half Goals 0.5,Over 0.5 Goals,1.44,WINNER,0.4114
Over/Under 0.5 Goals,Over 0.5 Goals,2.06,WINNER,0.9911
First Half Goals 0.5,Under 0.5 Goals,2.32,WINNER,1.2342
First Half Goals 0.5,Under 0.5 Goals,1.87,WINNER,0.8134500000000001
Over/Under 2.5 Goals,Under 2.5 Goals,1.2,WINNER,0.1869999999999999
First Half Goals 0.5,Under 0.5 Goals,1.08,WINNER,0.0748
First Half Goals 0.5,Over 0.5 Goals,2.02,WINNER,0.9537
Over/Under 1.5 Goals,Under 1.5 Goals,1.69,WINNER,0.64515
Over/Under 0.5 Goals,Over 0.5 Goals,1.25,LOSER,-1.0
Over/Under 0.5 Goals,Under 0.5 Goals,4.7,WINNER,3.4595
First Half Goals 0.5,Over 0.5 Goals,1.74,WINNER,0.6919000000000001
First Half Goals 1.5,Under 1.5 Goals,1.41,LOSER,-1.0
Over/Under 0.5 Goals,Under 0.5 Goals,4.3,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,2.44,WINNER,1.3464
Over/Under 1.5 Goals,Over 1.5 Goals,1.6,WINNER,0.5610000000000002
First Half Goals 0.5,Under 0.5 Goals,1.77,WINNER,0.7199500000000001
First Half Goals 1.5,Under 1.5 Goals,1.88,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.93,LOSER,-1.0
Over/Under 0.5 Goals,Under 0.5 Goals,1.62,WINNER,0.5797000000000001
Over/Under 3.5 Goals,Under 3.5 Goals,1.93,WINNER,0.86955
First Half Goals 0.5,Under 0.5 Goals,1.4,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.31,WINNER,0.28985
First Half Goals 0.5,Under 0.5 Goals,1.23,WINNER,0.21505
Over/Under 1.5 Goals,Under 1.5 Goals,1.75,WINNER,0.70125
Over/Under 2.5 Goals,Under 2.5 Goals,1.24,WINNER,0.2244
Over/Under 3.5 Goals,Under 3.5 Goals,1.1,WINNER,0.0935
First Half Goals 0.5,Under 0.5 Goals,1.13,WINNER,0.1215499999999999
Over/Under 5.5 Goals,Under 5.5 Goals,1.15,WINNER,0.1402499999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.4,WINNER,0.3739999999999999
Over/Under 0.5 Goals,Under 0.5 Goals,3.7,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,1.7,LOSER,-1.0
Over/Under 1.5 Goals,Under 1.5 Goals,4.0,WINNER,2.805
First Half Goals 0.5,Over 0.5 Goals,1.73,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.17,WINNER,0.1589499999999999
First Half Goals 0.5,Over 0.5 Goals,1.97,WINNER,0.90695
Over/Under 0.5 Goals,Under 0.5 Goals,5.6,WINNER,4.301
Over/Under 1.5 Goals,Over 1.5 Goals,1.44,WINNER,0.4114
First Half Goals 0.5,Over 0.5 Goals,1.75,WINNER,0.70125
First Half Goals 0.5,Over 0.5 Goals,1.87,WINNER,0.8134500000000001
Over/Under 0.5 Goals,Over 0.5 Goals,2.02,WINNER,0.9537
First Half Goals 0.5,Under 0.5 Goals,1.75,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.61,WINNER,0.5703500000000001
Over/Under 0.5 Goals,Under 0.5 Goals,2.26,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,2.02,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.8,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.4,WINNER,0.3739999999999999
Over/Under 2.5 Goals,Under 2.5 Goals,2.32,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.27,WINNER,0.25245
First Half Goals 0.5,Under 0.5 Goals,1.5,LOSER,-1.0
Over/Under 2.5 Goals,Under 2.5 Goals,1.06,WINNER,0.0561
Over/Under 4.5 Goals,Over 4.5 Goals,3.3,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.18,WINNER,0.1682999999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.41,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,1.9,WINNER,0.8414999999999999
First Half Goals 0.5,Under 0.5 Goals,1.04,WINNER,0.0374
First Half Goals 1.5,Over 1.5 Goals,2.02,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.73,WINNER,0.68255
Over/Under 4.5 Goals,Over 4.5 Goals,1.47,WINNER,0.43945
Over/Under 2.5 Goals,Over 2.5 Goals,1.33,WINNER,0.3085500000000001
Over/Under 1.5 Goals,Over 1.5 Goals,2.08,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.33,WINNER,0.3085500000000001
First Half Goals 1.5,Under 1.5 Goals,1.42,WINNER,0.3926999999999999
First Half Goals 0.5,Under 0.5 Goals,1.25,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.5,WINNER,0.4675
First Half Goals 0.5,Over 0.5 Goals,2.02,WINNER,0.9537
First Half Goals 0.5,Under 0.5 Goals,1.5,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.98,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.11,WINNER,0.1028500000000001
First Half Goals 0.5,Under 0.5 Goals,1.03,WINNER,0.02805
First Half Goals 0.5,Over 0.5 Goals,2.42,WINNER,1.3277
First Half Goals 0.5,Under 0.5 Goals,1.23,LOSER,-1.0
Over/Under 4.5 Goals,Over 4.5 Goals,4.7,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.71,WINNER,0.66385
Over/Under 2.5 Goals,Over 2.5 Goals,1.67,WINNER,0.62645
Over/Under 1.5 Goals,Under 1.5 Goals,1.54,WINNER,0.5049
First Half Goals 1.5,Under 1.5 Goals,1.46,WINNER,0.4301
First Half Goals 1.5,Under 1.5 Goals,1.13,WINNER,0.1215499999999999
First Half Goals 0.5,Under 0.5 Goals,1.2,WINNER,0.1869999999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.84,WINNER,0.7854000000000001
First Half Goals 0.5,Over 0.5 Goals,1.68,WINNER,0.6358
Over/Under 1.5 Goals,Over 1.5 Goals,1.73,LOSER,-1.0
Over/Under 1.5 Goals,Under 1.5 Goals,1.27,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.73,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.24,WINNER,0.2244
First Half Goals 0.5,Under 0.5 Goals,2.0,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.9,WINNER,0.8414999999999999
First Half Goals 1.5,Under 1.5 Goals,1.33,WINNER,0.3085500000000001
First Half Goals 0.5,Over 0.5 Goals,2.02,WINNER,0.9537
First Half Goals 0.5,Under 0.5 Goals,1.51,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.23,WINNER,0.21505
Over/Under 2.5 Goals,Over 2.5 Goals,1.29,WINNER,0.27115
First Half Goals 1.5,Over 1.5 Goals,2.02,WINNER,0.9537
Over/Under 3.5 Goals,Over 3.5 Goals,1.68,LOSER,-1.0
Over/Under 1.5 Goals,Under 1.5 Goals,1.18,WINNER,0.1682999999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.16,WINNER,0.1495999999999999
First Half Goals 0.5,Under 0.5 Goals,2.3,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.77,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.94,WINNER,0.8789
First Half Goals 0.5,Under 0.5 Goals,1.87,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.14,WINNER,0.1308999999999999
Over/Under 2.5 Goals,Over 2.5 Goals,1.24,LOSER,-1.0
Over/Under 0.5 Goals,Over 0.5 Goals,1.21,WINNER,0.1963499999999999
First Half Goals 1.5,Over 1.5 Goals,1.91,WINNER,0.85085
Over/Under 2.5 Goals,Over 2.5 Goals,1.77,LOSER,-1.0
Over/Under 0.5 Goals,Over 0.5 Goals,1.82,WINNER,0.7667
Over/Under 1.5 Goals,Under 1.5 Goals,2.14,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.16,WINNER,0.1495999999999999
First Half Goals 1.5,Under 1.5 Goals,1.11,WINNER,0.1028500000000001
Over/Under 0.5 Goals,Over 0.5 Goals,1.71,LOSER,-1.0
First Half Goals 1.5,Over 1.5 Goals,1.85,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.48,WINNER,0.4488
First Half Goals 1.5,Under 1.5 Goals,1.87,WINNER,0.8134500000000001
Over/Under 1.5 Goals,Over 1.5 Goals,1.26,WINNER,0.2431
Over/Under 1.5 Goals,Over 1.5 Goals,1.18,WINNER,0.1682999999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.47,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.58,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.46,WINNER,0.4301
Over/Under 1.5 Goals,Over 1.5 Goals,1.83,WINNER,0.7760500000000001
Over/Under 2.5 Goals,Over 2.5 Goals,2.58,LOSER,-1.0
Over/Under 1.5 Goals,Under 1.5 Goals,1.42,LOSER,-1.0
First Half Goals 2.5,Under 2.5 Goals,1.42,WINNER,0.3926999999999999
First Half Goals 0.5,Over 0.5 Goals,2.1,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,2.04,WINNER,0.9724
Over/Under 1.5 Goals,Under 1.5 Goals,1.26,WINNER,0.2431
First Half Goals 0.5,Under 0.5 Goals,1.4,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.95,WINNER,0.88825
First Half Goals 1.5,Under 1.5 Goals,1.32,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.29,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.16,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.3,WINNER,0.2805000000000001
First Half Goals 0.5,Over 0.5 Goals,1.45,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.58,WINNER,0.5423000000000001
Over/Under 2.5 Goals,Under 2.5 Goals,1.76,WINNER,0.7106
Over/Under 0.5 Goals,Over 0.5 Goals,1.54,WINNER,0.5049
Over/Under 4.5 Goals,Under 4.5 Goals,1.63,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.18,WINNER,0.1682999999999999
Over/Under 2.5 Goals,Over 2.5 Goals,1.71,WINNER,0.66385
Over/Under 2.5 Goals,Under 2.5 Goals,1.95,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,2.8,WINNER,1.6829999999999998
Over/Under 3.5 Goals,Under 3.5 Goals,2.2,WINNER,1.1220000000000003
Over/Under 1.5 Goals,Over 1.5 Goals,2.16,LOSER,-1.0
Over/Under 2.5 Goals,Under 2.5 Goals,1.5,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.27,WINNER,0.25245
Over/Under 6.5 Goals,Under 6.5 Goals,2.0,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,2.06,WINNER,0.9911
Over/Under 3.5 Goals,Under 3.5 Goals,1.9,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,2.08,WINNER,1.0098
Over/Under 1.5 Goals,Over 1.5 Goals,1.54,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.4,LOSER,-1.0
Over/Under 3.5 Goals,Under 3.5 Goals,3.35,WINNER,2.1972500000000004
Over/Under 2.5 Goals,Over 2.5 Goals,1.44,WINNER,0.4114
Over/Under 5.5 Goals,Over 5.5 Goals,1.33,WINNER,0.3085500000000001
Over/Under 1.5 Goals,Under 1.5 Goals,1.94,WINNER,0.8789
Over/Under 3.5 Goals,Under 3.5 Goals,1.01,WINNER,0.00935
First Half Goals 1.5,Under 1.5 Goals,1.78,WINNER,0.7293000000000001
First Half Goals 0.5,Over 0.5 Goals,1.63,WINNER,0.58905
First Half Goals 0.5,Over 0.5 Goals,1.75,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,2.38,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.37,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.4,WINNER,0.3739999999999999
First Half Goals 2.5,Under 2.5 Goals,1.01,WINNER,0.00935
Over/Under 1.5 Goals,Under 1.5 Goals,1.93,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.14,WINNER,0.1308999999999999
First Half Goals 0.5,Over 0.5 Goals,1.47,WINNER,0.43945
Over/Under 3.5 Goals,Over 3.5 Goals,1.55,WINNER,0.5142500000000001
Over/Under 1.5 Goals,Over 1.5 Goals,1.1,WINNER,0.0935
First Half Goals 0.5,Under 0.5 Goals,1.4,WINNER,0.3739999999999999
Over/Under 2.5 Goals,Over 2.5 Goals,3.0,LOSER,-1.0
Over/Under 2.5 Goals,Under 2.5 Goals,1.04,WINNER,0.0374
First Half Goals 0.5,Under 0.5 Goals,1.28,WINNER,0.2618
First Half Goals 1.5,Under 1.5 Goals,1.32,WINNER,0.2992000000000001
Over/Under 0.5 Goals,Over 0.5 Goals,1.33,WINNER,0.3085500000000001
Over/Under 0.5 Goals,Over 0.5 Goals,1.31,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,1.38,WINNER,0.3552999999999999
First Half Goals 2.5,Under 2.5 Goals,1.3,WINNER,0.2805000000000001
Over/Under 1.5 Goals,Over 1.5 Goals,1.3,WINNER,0.2805000000000001
First Half Goals 0.5,Under 0.5 Goals,1.65,WINNER,0.6077499999999999
First Half Goals 0.5,Under 0.5 Goals,1.39,WINNER,0.3646499999999999
First Half Goals 0.5,Over 0.5 Goals,1.71,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,1.85,WINNER,0.7947500000000002
First Half Goals 0.5,Under 0.5 Goals,1.72,WINNER,0.6732
Over/Under 0.5 Goals,Under 0.5 Goals,1.66,WINNER,0.6171
Over/Under 0.5 Goals,Under 0.5 Goals,2.92,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,2.5,WINNER,1.4025
Over/Under 1.5 Goals,Under 1.5 Goals,1.31,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.22,WINNER,0.2057
Over/Under 2.5 Goals,Over 2.5 Goals,1.08,WINNER,0.0748
Over/Under 1.5 Goals,Over 1.5 Goals,1.17,WINNER,0.1589499999999999
Over/Under 0.5 Goals,Over 0.5 Goals,1.24,WINNER,0.2244
Over/Under 1.5 Goals,Over 1.5 Goals,1.58,LOSER,-1.0
Over/Under 2.5 Goals,Under 2.5 Goals,1.66,LOSER,-1.0
Over/Under 3.5 Goals,Under 3.5 Goals,1.47,WINNER,0.43945
Over/Under 3.5 Goals,Over 3.5 Goals,1.12,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,2.16,LOSER,-1.0
Over/Under 1.5 Goals,Under 1.5 Goals,3.25,WINNER,2.10375
Over/Under 1.5 Goals,Under 1.5 Goals,3.1,WINNER,1.9635
Over/Under 0.5 Goals,Over 0.5 Goals,1.48,WINNER,0.4488
Over/Under 2.5 Goals,Over 2.5 Goals,1.21,WINNER,0.1963499999999999
Over/Under 3.5 Goals,Over 3.5 Goals,1.23,WINNER,0.21505
Over/Under 2.5 Goals,Under 2.5 Goals,4.7,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.29,WINNER,0.27115
Over/Under 3.5 Goals,Under 3.5 Goals,1.05,WINNER,0.04675
First Half Goals 0.5,Under 0.5 Goals,2.04,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.15,WINNER,0.1402499999999999
Over/Under 3.5 Goals,Over 3.5 Goals,1.43,WINNER,0.4020499999999999
Over/Under 0.5 Goals,Over 0.5 Goals,1.49,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.28,WINNER,0.2618
Over/Under 1.5 Goals,Under 1.5 Goals,5.4,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.45,WINNER,0.4207499999999999
Over/Under 1.5 Goals,Under 1.5 Goals,1.19,WINNER,0.1776499999999999
Over/Under 2.5 Goals,Under 2.5 Goals,1.38,WINNER,0.3552999999999999
First Half Goals 0.5,Under 0.5 Goals,1.42,LOSER,-1.0
Over/Under 0.5 Goals,Over 0.5 Goals,1.33,LOSER,-1.0
Over/Under 0.5 Goals,Over 0.5 Goals,1.3,WINNER,0.2805000000000001
Over/Under 3.5 Goals,Over 3.5 Goals,1.28,WINNER,0.2618
Over/Under 1.5 Goals,Under 1.5 Goals,2.94,LOSER,-1.0
Over/Under 2.5 Goals,Under 2.5 Goals,1.95,LOSER,-1.0
Over/Under 0.5 Goals,Under 0.5 Goals,1.87,WINNER,0.8134500000000001
Over/Under 1.5 Goals,Under 1.5 Goals,1.27,WINNER,0.25245
Over/Under 4.5 Goals,Over 4.5 Goals,1.09,WINNER,0.08415
Over/Under 3.5 Goals,Under 3.5 Goals,1.01,WINNER,0.00935
Over/Under 1.5 Goals,Over 1.5 Goals,2.14,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.02,WINNER,0.0187
Over/Under 4.5 Goals,Over 4.5 Goals,1.17,WINNER,0.1589499999999999
Over/Under 5.5 Goals,Over 5.5 Goals,1.24,WINNER,0.2244
First Half Goals 0.5,Under 0.5 Goals,1.4,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.35,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,1.51,LOSER,-1.0
First Half Goals 1.5,Over 1.5 Goals,2.62,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.81,WINNER,0.7573500000000001
Over/Under 0.5 Goals,Over 0.5 Goals,1.2,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.36,WINNER,0.3366000000000001
First Half Goals 0.5,Over 0.5 Goals,1.63,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.8,WINNER,0.7480000000000001
First Half Goals 0.5,Under 0.5 Goals,1.68,WINNER,0.6358
Over/Under 0.5 Goals,Under 0.5 Goals,1.27,WINNER,0.25245
Over/Under 1.5 Goals,Over 1.5 Goals,1.59,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.59,WINNER,0.5516500000000001
Over/Under 2.5 Goals,Over 2.5 Goals,1.62,WINNER,0.5797000000000001
Over/Under 0.5 Goals,Over 0.5 Goals,1.64,LOSER,-1.0
Over/Under 4.5 Goals,Over 4.5 Goals,1.34,WINNER,0.3179
Over/Under 4.5 Goals,Over 4.5 Goals,1.34,WINNER,0.3179
First Half Goals 0.5,Under 0.5 Goals,1.6,WINNER,0.5610000000000002
Over/Under 1.5 Goals,Over 1.5 Goals,2.1,LOSER,-1.0
Over/Under 5.5 Goals,Under 5.5 Goals,1.52,LOSER,-1.0
Over/Under 2.5 Goals,Under 2.5 Goals,1.19,WINNER,0.1776499999999999
Over/Under 0.5 Goals,Over 0.5 Goals,1.2,WINNER,0.1869999999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.1,WINNER,0.0935
Over/Under 3.5 Goals,Under 3.5 Goals,1.27,LOSER,-1.0
Over/Under 7.5 Goals,Under 7.5 Goals,1.38,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.87,LOSER,-1.0
Over/Under 1.5 Goals,Under 1.5 Goals,2.14,LOSER,-1.0
Over/Under 3.5 Goals,Under 3.5 Goals,1.22,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.5,WINNER,0.4675
First Half Goals 0.5,Under 0.5 Goals,1.12,WINNER,0.1122000000000001
First Half Goals 2.5,Under 2.5 Goals,1.27,WINNER,0.25245
First Half Goals 0.5,Under 0.5 Goals,1.21,WINNER,0.1963499999999999
Over/Under 2.5 Goals,Over 2.5 Goals,1.19,WINNER,0.1776499999999999
Over/Under 2.5 Goals,Over 2.5 Goals,1.25,WINNER,0.23375
Over/Under 2.5 Goals,Under 2.5 Goals,2.48,LOSER,-1.0
First Half Goals 1.5,Over 1.5 Goals,1.72,WINNER,0.6732
First Half Goals 0.5,Over 0.5 Goals,1.62,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,1.52,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,2.38,WINNER,1.2903
First Half Goals 0.5,Under 0.5 Goals,1.82,WINNER,0.7667
First Half Goals 0.5,Under 0.5 Goals,2.24,WINNER,1.1594000000000002
Over/Under 0.5 Goals,Over 0.5 Goals,1.28,WINNER,0.2618
Over/Under 0.5 Goals,Under 0.5 Goals,4.0,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,1.77,LOSER,-1.0
Over/Under 0.5 Goals,Under 0.5 Goals,3.15,WINNER,2.01025
Over/Under 0.5 Goals,Over 0.5 Goals,1.66,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.15,WINNER,0.1402499999999999
First Half Goals 0.5,Under 0.5 Goals,2.42,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.28,LOSER,-1.0
Over/Under 2.5 Goals,Under 2.5 Goals,1.28,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.55,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.51,WINNER,0.47685
First Half Goals 1.5,Under 1.5 Goals,1.32,LOSER,-1.0
Over/Under 3.5 Goals,Under 3.5 Goals,1.33,WINNER,0.3085500000000001
First Half Goals 0.5,Under 0.5 Goals,2.18,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.82,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,1.63,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.29,WINNER,0.27115
First Half Goals 1.5,Over 1.5 Goals,1.47,WINNER,0.43945
First Half Goals 1.5,Over 1.5 Goals,1.76,WINNER,0.7106
First Half Goals 0.5,Under 0.5 Goals,1.3,WINNER,0.2805000000000001
First Half Goals 2.5,Under 2.5 Goals,1.54,WINNER,0.5049
Over/Under 4.5 Goals,Over 4.5 Goals,1.12,WINNER,0.1122000000000001
Over/Under 0.5 Goals,Over 0.5 Goals,1.28,LOSER,-1.0
Over/Under 4.5 Goals,Over 4.5 Goals,1.16,WINNER,0.1495999999999999
Over/Under 0.5 Goals,Under 0.5 Goals,1.95,WINNER,0.88825
Over/Under 0.5 Goals,Under 0.5 Goals,2.36,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.57,WINNER,0.53295
First Half Goals 0.5,Under 0.5 Goals,1.44,LOSER,-1.0
Over/Under 3.5 Goals,Under 3.5 Goals,1.86,WINNER,0.8041000000000001
Over/Under 2.5 Goals,Under 2.5 Goals,2.18,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.22,WINNER,0.2057
Over/Under 0.5 Goals,Over 0.5 Goals,1.23,WINNER,0.21505
First Half Goals 0.5,Over 0.5 Goals,2.26,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.45,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.58,WINNER,0.5423000000000001
First Half Goals 1.5,Under 1.5 Goals,1.3,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.25,WINNER,0.23375
First Half Goals 0.5,Over 0.5 Goals,1.32,WINNER,0.2992000000000001
Over/Under 0.5 Goals,Under 0.5 Goals,1.22,WINNER,0.2057
First Half Goals 1.5,Over 1.5 Goals,2.44,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.21,LOSER,-1.0
Over/Under 0.5 Goals,Over 0.5 Goals,1.29,WINNER,0.27115
Over/Under 0.5 Goals,Over 0.5 Goals,1.72,WINNER,0.6732
Over/Under 0.5 Goals,Under 0.5 Goals,2.5,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.99,WINNER,0.92565
Over/Under 3.5 Goals,Over 3.5 Goals,1.65,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.54,WINNER,0.5049
Over/Under 1.5 Goals,Under 1.5 Goals,1.67,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.43,WINNER,0.4020499999999999
First Half Goals 0.5,Under 0.5 Goals,1.46,WINNER,0.4301
First Half Goals 1.5,Under 1.5 Goals,1.2,WINNER,0.1869999999999999
First Half Goals 2.5,Under 2.5 Goals,1.16,WINNER,0.1495999999999999
Over/Under 4.5 Goals,Over 4.5 Goals,1.16,WINNER,0.1495999999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.23,WINNER,0.21505
Over/Under 1.5 Goals,Over 1.5 Goals,1.24,WINNER,0.2244
Over/Under 4.5 Goals,Over 4.5 Goals,1.19,WINNER,0.1776499999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.61,WINNER,0.5703500000000001
Over/Under 3.5 Goals,Over 3.5 Goals,1.47,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.83,WINNER,0.7760500000000001
Over/Under 0.5 Goals,Under 0.5 Goals,2.0,WINNER,0.935
First Half Goals 2.5,Under 2.5 Goals,1.46,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,2.36,WINNER,1.2716
Over/Under 3.5 Goals,Under 3.5 Goals,1.6,LOSER,-1.0
Over/Under 3.5 Goals,Under 3.5 Goals,1.68,WINNER,0.6358
Over/Under 2.5 Goals,Under 2.5 Goals,1.52,WINNER,0.4862
Over/Under 3.5 Goals,Under 3.5 Goals,1.3,WINNER,0.2805000000000001
First Half Goals 0.5,Over 0.5 Goals,1.82,WINNER,0.7667
Over/Under 1.5 Goals,Under 1.5 Goals,4.1,LOSER,-1.0
First Half Goals 0.5,Over 0.5 Goals,1.75,WINNER,0.70125
First Half Goals 0.5,Under 0.5 Goals,1.48,LOSER,-1.0
Over/Under 0.5 Goals,Under 0.5 Goals,1.53,LOSER,-1.0
Over/Under 4.5 Goals,Under 4.5 Goals,1.22,WINNER,0.2057
First Half Goals 1.5,Under 1.5 Goals,1.86,WINNER,0.8041000000000001
Over/Under 0.5 Goals,Under 0.5 Goals,1.73,WINNER,0.68255
Over/Under 0.5 Goals,Under 0.5 Goals,1.2,WINNER,0.1869999999999999
Over/Under 2.5 Goals,Under 2.5 Goals,1.58,WINNER,0.5423000000000001
First Half Goals 0.5,Under 0.5 Goals,1.28,WINNER,0.2618
Over/Under 2.5 Goals,Over 2.5 Goals,1.28,LOSER,-1.0
Over/Under 3.5 Goals,Over 3.5 Goals,1.23,WINNER,0.21505
Over/Under 2.5 Goals,Over 2.5 Goals,1.31,WINNER,0.28985
Over/Under 1.5 Goals,Under 1.5 Goals,3.05,LOSER,-1.0
Over/Under 0.5 Goals,Over 0.5 Goals,1.16,WINNER,0.1495999999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.24,WINNER,0.2244
Over/Under 0.5 Goals,Over 0.5 Goals,1.21,WINNER,0.1963499999999999
Over/Under 0.5 Goals,Over 0.5 Goals,1.45,WINNER,0.4207499999999999
Over/Under 0.5 Goals,Over 0.5 Goals,1.4,LOSER,-1.0
Over/Under 0.5 Goals,Over 0.5 Goals,2.2,LOSER,-1.0
Over/Under 2.5 Goals,Over 2.5 Goals,1.56,WINNER,0.5236000000000001
Over/Under 0.5 Goals,Over 0.5 Goals,2.74,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.18,WINNER,0.1682999999999999
Over/Under 1.5 Goals,Over 1.5 Goals,1.21,WINNER,0.1963499999999999
First Half Goals 1.5,Under 1.5 Goals,2.18,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.05,WINNER,0.04675
Over/Under 1.5 Goals,Over 1.5 Goals,1.27,WINNER,0.25245
First Half Goals 0.5,Over 0.5 Goals,1.89,WINNER,0.83215
First Half Goals 0.5,Over 0.5 Goals,1.8,LOSER,-1.0
Over/Under 1.5 Goals,Over 1.5 Goals,1.9,LOSER,-1.0
Over/Under 0.5 Goals,Under 0.5 Goals,1.75,WINNER,0.70125
Over/Under 1.5 Goals,Over 1.5 Goals,1.3,WINNER,0.2805000000000001
First Half Goals 1.5,Over 1.5 Goals,1.7,WINNER,0.6545
First Half Goals 0.5,Over 0.5 Goals,1.78,LOSER,-1.0
First Half Goals 1.5,Under 1.5 Goals,1.84,LOSER,-1.0
First Half Goals 0.5,Under 0.5 Goals,1.97,WINNER,0.90695
Over/Under 1.5 Goals,Over 1.5 Goals,1.23,WINNER,0.21505
Over/Under 2.5 Goals,Over 2.5 Goals,1.3,LOSER,-1.0
First Half Goals 2.5,Under 2.5 Goals,1.3,WINNER,0.2805000000000001
Over/Under 1.5 Goals,Over 1.5 Goals,1.38,LOSER,-1.0
Over/Under 1.5 Goals,Under 1.5 Goals,2.2,LOSER,-1.0

This CSV file contains the results of my investments.

The column containing the profit/loss is the column named back

And I want to test it like this:

Let's assume that I want to see the total profit only for the investments I would make if according to some filters this investment pattern was profitable in previous records.

Example:

The 51st investment is 'market_name' → Over/Under 2.5 Goals, 'runner_name' → Under 2.5 Goals and 'odds' → 1.24

So I want to sum the profit/loss of 50th previous investments if they have these same filters, if the sum of these filters is greater than zero, then I make investment 51.

And so on in each of the lines, 100th investment, I see if the previous 99 investments filtering the cited options will be profitable, if so, I add the back column of 100th to the list for final sum.

So I created this code:

import pandas as pd

df = pd.read_csv(test.csv')
df = df[df['result'].notnull()]

matches = []

for number in range(len(df)):
    try:
        dfilter = df[:number]
        filter = dfilter[(dfilter['market_name'] == df['market_name'][number 1]) & (dfilter['runner_name'] == df['runner_name'][number 1]) & (dfilter['odds'] == df['odds'][number 1])]
        back_sum = filter['back'].sum()
        if back_sum > 0:
            matches.append(df['back'][number 1])
    except:
        pass

print(sum(matches))

But the final sum is delivering a result that does not match my real results where I invest.

I can't find where the flaw is in the code because it looks correct to me visually.

CodePudding user response:

Slice df[:number] means to take elements up to number. And when referring to the current line, you must use number, not number 1. This can be checked, for example, print df[:3] and get all the lines up to the third one.

But if you use loc, then operations through the slice will not be up to, but inclusive (you should not forget about this). That is, with df.loc[:3, :] rows will be selected, including the third one.

That is, you need this:

for number in range(len(df)):
    try:
        dfilter = df[:number]
        filter = dfilter[(dfilter['market_name'] == df['market_name'][number]) &
                         (dfilter['runner_name'] == df['runner_name'][number]) & (dfilter['odds'] == df['odds'][number])]

        back_sum = filter['back'].sum()
        if back_sum > 0:
            matches.append(df['back'][number])
    except:
        pass

If the dataframe is large, the loop will be slow. I can recommend List comprehension, which is many times faster than a loop. Below I made a column 'invest', where, depending on back_sum, the values will be True or False.

df = pd.read_csv('test.csv')

#df = df[df['result'].notnull()].reset_index(drop=True)
"""
is whether all indexes of the original dataframe are needed,
if not, then you can add this line and use the filtered dataframe(if you need a filtered dataframe,
uncomment this line df = df[df['result'].notnull()].reset_index(drop=True))
"""

def my_func(i):
    dfilter = df[:i]
    filter = dfilter[(dfilter['market_name'] == df['market_name'][i]) &
                     (dfilter['runner_name'] == df['runner_name'][i]) & (dfilter['odds'] == df['odds'][i])]
    back_sum = filter['back'].sum()
    aaa = True
    if back_sum <= 0:
        aaa = False

    return aaa

df['invest'] = [my_func(i) for i in range(len(df))]
  • Related