title: Pandas: handle one-row dataframes with iloc
body: <p>I am using a dataframe (df1) inside a loop to store information that I read from another dataframe (df2). df1 can have different number of rows in every iteration. I store the data row by row using <code>df1.loc[row_number]</code>. This could be an example:</p>
  
  <pre><code>   a  b  c
  0  9  2  3
  1  8  5  6
  2  3  8  9
  </code></pre>
  
  <p>Then I need to read the value of the first column and the first row, which I perform as</p>
  
  <pre><code>df1['a'].iloc[0]
  9
  </code></pre>
  
  <p>The problem arises when df1 is a one row dataframe:</p>
  
  <pre><code>a    9
  b    2
  c    3
  Name: 0, dtype: int64
  </code></pre>
  
  <p>It seems that with only one row, pandas stores the dataframe as a pandas series object. Trying to access the value in the same way ( <code>df1['a'].iloc[0]</code> ) I get the error:</p>
  
  <pre><code>AttributeError: 'numpy.int64' object has no attribute 'iloc'
  </code></pre>
  
  <p>Is there a way to solve this in a general case, with no need to handle the 1-row dataframe separately?</p>