I got a dataframe combined by with index = datetime
and column = {'currentprice'}
index currentPrice
2015-03-26 10:09:01 75.75
2015-03-26 10:11:57 75.70
Now I want to get the delta value during every 3 minutes(as an example), the I can get a dataframe like this:
index delta
2015-03-26 10:09:01 -0.05
2015-03-26 10:11:57 0.10
...
What should I do?
To expand upon the answer given in the comments, you can use
df['delta'] = df.currentPrice.diff().shift(-1)
to get the difference between the price in one row and the next. However if you're actually interested in finding the difference between time periods separated by 3 minutes, not the 2m56s in your data, you're going to need to resample your timeseries using the resample method as documented here: http://pandas.pydata.org/pandas-docs/dev/timeseries.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With