title: Python IndexError: index 0 is out of bounds for axis 0 with size 0
body: <p>I'm trying to match 1000 images (listing) with 1000 labels which are are in "trainLabels" dataFrame. I had created this loop that worked well until I tried to remove those images that had low quallity. 
  I have removed with the .drop() function the corresponding rows in the dataFrame trainLabels and I have reseted its index with .reset_index(), but I could not solve it. Any suggestions?</p>
  
  <pre><code>from PIL import Image 
  
  
  img_rows, img_cols = 200, 200 # desired size for images 
  
  
  immatrix = [] 
  imlabel = [] 
  
  for file in listing: 
  
      base = os.path.basename("../input/" + file) 
      fileName = os.path.splitext(base) [0] #consigue el nombre del archivo sin la extensión
      imlabel.append(trainLabels.loc[trainLabels.image==fileName,"level"].values[0]) 
      im = Image.open("../input/" + file)
      img = im.resize((img_rows,img_cols))
      gray = img.convert("L") 
      immatrix.append(np.array(gray).flatten()) 
  </code></pre>
  
  <p>Error message</p>
  
  <pre><code>&gt; IndexError                                Traceback (most recent call
  &gt; last)
  &gt;     &lt;ipython-input-45-6c7731e1f46b&gt; in &lt;module&gt;()
  &gt;           9     base = os.path.basename("../input/" + file)
  &gt;          10     fileName = os.path.splitext(base) [0] #consigue el nombre del archivo sin la extensión
  &gt;     ---&gt; 11     imlabel.append(trainLabels.loc[trainLabels.image==fileName,"level"].values[0])
  &gt;          12     im = Image.open("../input/" + file)
  &gt;          13     img = im.resize((img_rows,img_cols))
  &gt;     
  &gt;     IndexError: index 0 is out of bounds for axis 0 with size 0
  </code></pre>