I have pandas df['realize']
time realize
2016-01-18 08:25:00 -46.369083
2016-01-19 14:30:00 -819.010738
2016-01-20 11:10:00 -424.955847
2016-01-21 07:15:00 27.523859
2016-01-21 16:10:00 898.522762
2016-01-25 00:00:00 761.063545
Where time is:
df.index = df['time']
df.index = pd.to_datetime(df.index)
Where df['realize'] is:
In: type(df['realize'])
Out: pandas.core.series.Series
I want to count consecutive values, rule is simple (df['realize'] > 0, df['realize'] < 0)
Expected out:
time realize Consecutive
2016-01-18 08:25:00 -46.369083 1
2016-01-19 14:30:00 -819.010738 2
2016-01-20 11:10:00 -424.955847 3
2016-01-21 07:15:00 27.523859 1
2016-01-21 16:10:00 898.522762 2
2016-01-25 00:00:00 761.063545 3
I read about topics about loop, but didn't find what I need. Thanks in advance for help.