title: Python iloc giving indexError: single positional indexer is out-of-bounds in simple for loop
body: <p>I have dataframe as given below:</p>
  
  <pre><code>df = 
            0
  1      0.993995
  2      1.111068
  3      1.760940
  .
  .
  .
  49    40.253574
  50    40.664486
  51    41.083962
  </code></pre>
  
  <p>I am iterating through each row and print each element. My code is given below:</p>
  
  <pre><code>for idx,row in df.iterrows():
      print(df[0].iloc[idx])
  </code></pre>
  
  <p>Present output: </p>
  
  <pre><code>1.111068
  1.76094
  2.691832
  .
  .
  40.664486
  41.083962
  Traceback (most recent call last):
  
    File "&lt;ipython-input-46-80539a9081e5&gt;", line 2, in &lt;module&gt;
      print(darkdf[0].iloc[idx])
  
    File "C:\Users\MM\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1500, in __getitem__
      return self._getitem_axis(maybe_callable, axis=axis)
  
    File "C:\Users\MM\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 2230, in _getitem_axis
      self._validate_integer(key, axis)
  
    File "C:\Users\MM\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 2139, in _validate_integer
      raise IndexError("single positional indexer is out-of-bounds")
  
  IndexError: single positional indexer is out-of-bounds
  </code></pre>
  
  <p>Why this simple function is giving error. Someone could help me to understand what the error is saying? </p>