def process():
active = ACTIVES[0]
df = pandas.read_csv(f'{active}.csv', index_col='time')
probs = df.groupby(['time']).candle.apply(lambda g: g.value_counts() / len(g))
print(probs)
result:
time
00:00 put 0.735294
call 0.264706
00:05 call 0.500000
put 0.352941
dogi 0.147059
...
23:50 call 0.666667
put 0.333333
23:55 call 0.500000
put 0.441176
dogi 0.058824
Name: candle, Length: 718, dtype: float64
now, how can I filter the TIME column by highest values(put/call) by at least higher or equal then 0.7 and filter the ones that the next TIME is equal or higher
example:
time
00:00 put 0.735294 #higher then 0.7, but do not include in the final resul because the next TIME (00:05) is not put
call 0.264706
00:05 call 0.500000
put 0.352941
dogi 0.147059
time
00:00 put 0.735294 #higher then 0.7, and the next TIME is a put and higher or equal a 0.7
call 0.264706
00:05 put 0.700000
call 0.300000
TIME column is in 5 in 5 min
UPDATE 01
what I have so far:
def process():
active = ACTIVES[0]
df = pandas.read_csv(f'{active}.csv', index_col='time', parse_dates=True)
df = df.groupby(['time']).candle.apply(lambda g: g.value_counts() / len(g)).reset_index()
print(df.query('candle > 0.7'))
print result:
time level_1 candle
0 2020-05-07 00:00:00 put 0.735294
20 2020-05-07 00:35:00 call 0.718750
58 2020-05-07 01:40:00 call 0.750000
371 2020-05-07 12:35:00 put 0.787879
487 2020-05-07 16:25:00 call 0.742857
625 2020-05-07 20:55:00 put 0.718750
663 2020-05-07 22:15:00 call 0.750000
now, how can I iterate over the rows and compare if the next TIME row is greater by 5min and level_1 is equal direction?
please excuse my english