Q:

How do i change index string to datetime in pandas?

I am trying to change the index string to index which is datetime in pandas dataframe. 
    High    Low Open    Close   Volume  Adj Close
Date                        
1987-12-31  1.535714    1.495536    1.517857    1.500000    29400000.0  1.200883
1988-01-04  1.598214    1.508929    1.526786    1.598214    82600000.0  1.279513
1988-01-05  1.651786    1.580357    1.642857    1.593750    77280000.0  1.275938
1988-01-06  1.607143    1.562500    1.607143    1.562500    67200000.0  1.250920
1988-01-07  1.598214    1.517857    1.553571    1.589286    53200000.0  1.272364
... ... ... ... ... ... ...
2007-12-24  28.475714   27.827143   27.861429   28.400000   120050700.0 24.785059
2007-12-26  28.708570   28.117144   28.430000   28.421429   175933100.0 24.803761
2007-12-27  28.994286   28.257143   28.421429   28.367144   198881900.0 24.756376
2007-12-28  28.794285   28.125713   28.655714   28.547142   174911800.0 24.913471
2007-12-31  28.642857   28.250000   28.500000   28.297142   134833300.0 24.695290

To change the date format i have tried to use the 
data['Date'] = data.to_datetime(data['Date'], format ='%Y-%m-%d')

However i am getting the following error: 
How can i change the index to datetime format?
AttributeError: 'DataFrame' object has no attribute 'to_datetime'

A:

pandas.to_datetime() is not a method on the dataframe object but instead from pandas module itself. (Docs)
Indexes can't be accessed using df['Date']. This syntax is for accessing columns.
If you want to access the index and change it's type to DateTime, try this:
data.index = pd.to_datetime(data.index, format ='%Y-%m-%d')

