title: Forcing pandas .iloc to return a single-row dataframe?
body: <p>For programming purpose, I want <code>.iloc</code> to consistently return a data frame, even when the resulting data frame has only one row. How to accomplish this?</p>
  
  <p>Currently, <code>.iloc</code> returns a Series when the result only has one row. Example:</p>
  
  <pre><code>In [1]: df = pd.DataFrame({'a':[1,2], 'b':[3,4]})
  
  In [2]: df
  Out[2]:
     a  b
  0  1  3
  1  2  4
  
  In [3]: type(df.iloc[0, :])
  Out[3]: pandas.core.series.Series
  </code></pre>
  
  <p>This behavior is poor for 2 reasons:</p>
  
  <ul>
  <li>Depending on the number of chosen rows, <code>.iloc</code> can either return a Series or a Data Frame, forcing me to manually check for this in my code</li>
  </ul>
  
  <p><strike>- <code>.loc</code>, on the other hand, always return a Data Frame, making <code>pandas</code> inconsistent within itself</strike> (wrong info, as pointed out in the comment)</p>
  
  <p>For the R user, this can be accomplished with <code>drop = FALSE</code>, or by using tidyverse's tibble, which always return a data frame by default.</p>