title: Seems that I have a wrong index somewhere, but cannot spot it
body: <p>I am new to python and having trouble with a function. It should delete rows of a (N,10) matrix (imported fron a file) where -1 appears. This is the code
  import pandas as pd
  import numpy as np</p>
  
  <pre><code>def load(name, f):
  
      file = pd.read_csv(name,header=None)
  
      totalMatrix = np.array(file)
  
      if f == 'forward':
  
          for i in range(len(totalMatrix)):
  
              for j in range(10):
  
                  if totalMatrix[i,j] ==-1: 
  
                      if i &gt; 0:
                          totalMatrix[i,j]=totalMatrix[i-1,j]
  
                      else:
                          print("Warning")
                          f = 'drop'
  
  
      elif f == 'drop':
  
          for i in range(len(totalMatrix)): # or np.size(totalMatrix[:, 0])
  
              for j in range(10):
  
                  if totalMatrix[i,j] == -1 : 
  
                      totalMatrix = np.delete(totalMatrix, (i), axis=0)
  
  
      t = totalMatrix[:, 0:6]
      d = totalMatrix[:, 6:11]
  
      return t, d
  </code></pre>
  
  <p>But I keep running on this error: </p>
  
  <pre><code>line 38, in load
  if totalMatrix[i,j] == -1 :
  
  IndexError: index 2 is out of bounds for axis 0 with size 2
  </code></pre>
  
  <p>I have tried to look several places on internet, but could not find an answer, neither could I find the error myself. Can anybody see what is wrong and tell me?</p>