title: pandas DataFrame selecting list of rows from DateTimeIndex - KeyError. Understanding why
body: <p>I'm trying to understand why I get this error. I already have a solution for this issue and it was actually solved <a href="https://stackoverflow.com/questions/45213834/pandas-extracting-multiple-rows-from-dataframe-with-list-of-datetimeindices">here</a>, just need to understand why it doesn't work as I was expecting.</p>
  
  <p>I would like to understand why this throws a KeyError:</p>
  
  <pre><code>dates = pd.date_range('20130101', periods=4)
  df = pd.DataFrame(np.identity(4), index=dates, columns=list('ABCD'))
  df.loc[['20130102', '20130103'],:]
  </code></pre>
  
  <p>with the following feedback:</p>
  
  <pre><code>KeyError: "None of [['20130102', '20130103']] are in the [index]"
  </code></pre>
  
  <p>As explained <a href="https://stackoverflow.com/questions/45213834/pandas-extracting-multiple-rows-from-dataframe-with-list-of-datetimeindices">here</a>, the solution is just to do:</p>
  
  <pre><code>df.loc[pd.to_datetime(['20130102','20130104']),:]
  </code></pre>
  
  <p>So the problem is definitely with the way loc takes the string list as argument for selecting from a DateTimeIndex. However, I can see that the following calls are ok for this function:</p>
  
  <pre><code>df.loc['20130102':'20130104',:]
  </code></pre>
  
  <p>and</p>
  
  <pre><code>df.loc['20130102']
  </code></pre>
  
  <p>I would like to understand how this works and would appreciate any resources I can use to predict the behavior of this function depending of how it is being called. I read <a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html" rel="nofollow noreferrer">Indexing and Selecting Data</a> and <a href="http://pandas.pydata.org/pandas-docs/stable/timeseries.html#datetimeindex-partial-string-indexing" rel="nofollow noreferrer">Time Series/Date functionality</a> from pandas documentation but couldn't find an explanation for this.</p>