IndexError: index is out of bounds for axis 0 python numpy -
i know python thinks there number. have know idea how fix this. advice appreciated.
import numpy test = numpy.array([9,1,3,4,8,7,2,5,6,5,-10,12,-15,19,-20,22,-53,45,43,43,23,-65,-23,46,44,67,79,5,-34,32,-56,-3,1,15,22,3]) n = 0 n1 = 3 while n < len(test): low = numpy.amin(test[n:n1]) close = test[n1] high = numpy.amax(test[n:n1]) stochastic = float(close-low)/(high-low)*100.00 print stochastic n1=n1+1 n=n+1
error:
indexerror: index 36 out of bounds axis 0 size 36
your need put stop condition on n1
instead of n
:
while n1 < len(test):
Comments
Post a Comment