2016-04-25 60 views
0

我知道python認爲有另一個數字。但我知道如何解決這個問題。任何建議表示讚賞。IndexError:索引超出軸0 python numpy

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 

錯誤:

indexError: index 36 is out of bounds for axis 0 with size 36 

回答

1

你需要把停止條件上的N1代替N

while N1 < len(test): 
+0

哇太感謝你了:)現在的工作 –

相關問題