title: Why am I getting this TypeError when I try to slice my Pandas DataFrame?
body: <p>I pulled some stock data from a financial API and created a DataFrame with it. Columns were 'date', 'data1', 'data2', 'data3'.  Then, I converted that DataFrame into a CSV with 'date' column as index:</p>
  
  <pre><code>df.to_csv('data.csv', index_label='date')
  </code></pre>
  
  <p>In a second script, I read that CSV and attempted to slice the resulting DataFrame between two dates:</p>
  
  <pre><code>df = pd.read_csv('data.csv', parse_dates=['date'] ,index_col='date')
  df = df['2020-03-28':'2020-04-28']
  </code></pre>
  
  <p>When I attempt to do this, I get the following TypeError:</p>
  
  <pre><code>TypeError: cannot do slice indexing on &lt;class 'pandas.core.indexes.numeric.Int64Index'&gt; with these indexers [2020-03-28] of &lt;class 'str'&gt;
  </code></pre>
  
  <p>So clearly, the problem is that I'm trying to use a str to slice a datetime object.  But here's the confusing part!  If in the first step, I save the DataFrame to a csv and DO NOT set 'date' as index:</p>
  
  <pre><code>df.to_csv('data.csv')
  </code></pre>
  
  <p>In my second script, I no longer get the TypeError:</p>
  
  <pre><code>df = pd.read_csv('data.csv', parse_dates=['date'] ,index_col='date')
  df = df['2020-03-28':'2020-04-28']
  </code></pre>
  
  <p>Now it works just fine.  The only problem is I have the default Pandas index column to deal with.</p>
  
  <p>Why do I get a TypeError when I set the 'date' column as index in my CSV...but I do NOT get a TypeError when I don't set any index in the CSV?</p>