Mar-26-2019, 03:29 PM
Hey guys
So in short, my Pandas dataframe is something like this:
https://www.dropbox.com/s/ja6kn0f55599xul/test.csv?dl=1
I want to pull out something like this:
I though something like the above piece of code would work, but no, it's giving me errors. I also tried a few other approaches to no avail so end up a bit lost.. The full csv dataframe is here: https://www.dropbox.com/s/9p3kt338bj20yd...8.csv?dl=1
Any suggestions or help will be very much appreciated, thanks! :)
So in short, my Pandas dataframe is something like this:
https://www.dropbox.com/s/ja6kn0f55599xul/test.csv?dl=1
I want to pull out something like this:
a = df.index - df.index.where(df.candle == df.candle -3)[0] df['test'] = df.bid.rolling(int(a)).mean()So basically, I want to look back X amount of periods with .rolling(), but I don't know exactly how many therefore I need to calculate it based on df.candle values. I want to look 3 candles back to be more precise and calculate the index difference to use inside .rolling()
I though something like the above piece of code would work, but no, it's giving me errors. I also tried a few other approaches to no avail so end up a bit lost.. The full csv dataframe is here: https://www.dropbox.com/s/9p3kt338bj20yd...8.csv?dl=1
Any suggestions or help will be very much appreciated, thanks! :)