python I want to set_index dateFrame with datetime
<pre><code>poorList = [datetime.date(2016, 5, 2), 
            datetime.date(2016, 8, 26), 
            datetime.date(2016, 6, 9), 
            datetime.date(2016, 3, 4)]

dateForm.set_index(poorList)
</code></pre>

<p>then it was Errorï¼</p>

<blockquote>
  <p>File "pandas\index.pyx", line 137, in pandas.index.IndexEngine.get_loc
  (pandas\index.c:4066)
         File "pandas\index.pyx", line 159, in pandas.index.IndexEngine.get_loc (pandas\index.c:3930)
         File "pandas\hashtable.pyx", line 675, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12408)
         File "pandas\hashtable.pyx", line 683, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12359)
       KeyError: datetime.date(2016, 5, 2)</p>
</blockquote>

<p>Please tell me how to do it ?</p>

<p>Another solutions is assign list converted <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.to_datetime.html" rel="nofollow"><code>to_datetime</code></a> or <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DatetimeIndex.html" rel="nofollow"><code>DatetimeIndex</code></a>:</p>

<pre><code>poorList = [datetime.date(2016, 5, 2), 
            datetime.date(2016, 8, 26), 
            datetime.date(2016, 6, 9), 
            datetime.date(2016, 3, 4)]

dateForm.index = pd.DatetimeIndex(poorList)

print (dateForm.index)
DatetimeIndex(['2016-05-02', '2016-08-26', '2016-06-09', '2016-03-04'], 
dtype='datetime64[ns]', freq=None)
</code></pre>

<p>Solution with sample:</p>

<pre><code>dateForm = pd.DataFrame({'A':[1,2,3,7],
                         'B':[4,5,6,8]})

print (dateForm)
   A  B
0  1  4
1  2  5
2  3  6
3  7  8

poorList = [datetime.date(2016, 5, 2), 
            datetime.date(2016, 8, 26), 
            datetime.date(2016, 6, 9), 
            datetime.date(2016, 3, 4)]

dateForm.index = pd.to_datetime(poorList)
print (dateForm)
            A  B
2016-05-02  1  4
2016-08-26  2  5
2016-06-09  3  6
2016-03-04  7  8

print (dateForm.index)
DatetimeIndex(['2016-05-02', '2016-08-26', '2016-06-09', '2016-03-04'], 
              dtype='datetime64[ns]', freq=None)
</code></pre>

python list date pandas datetimeindex