Q:

Plotting with matplotlib does not give desired datetime format

the data i used are derived from an excel file using pd.read_excel.
The objective: To plot DateTime vs Value with x axis values in the format %Y-%m-%d %H:%M:%S.
The problem: The X axis format is not the desired %Y-%m-%d %H:%M:%S. 
Below is a snippet of the code i used and its result. I am very new to programming in general and will really appreciate it if you guys can point me in the right direction!
>>> df.head()

            DateTime  Value
0 2016-05-17 22:50:27   1914
1 2016-05-17 22:55:27   1597
2 2016-05-17 23:00:27   1429
3 2016-05-17 23:05:27   1462
4 2016-05-17 23:10:27   2038

>>> df['DateTime'] = pd.to_datetime(df['DateTime'], format='%Y-%m-%d %H:%M:%S')

>>> df.plot(x='DateTime', y='Value')

>>> plt.show()

Plot of DateTime vs Value:

A:

You can use matplotlib.dates.DateFormatter to achieve this:
import matplotlib.dates as dates
df['DateTime'] = pd.to_datetime(df['DateTime'], format='%Y-%m-%d %H:%M:%S')
df.plot(x='DateTime', y='Value')
formatter = dates.DateFormatter('%Y-%m-%d %H:%M:%S') 
plt.gcf().axes[0].xaxis.set_major_formatter(formatter)

results in:

to_datetime converts strings to datetime64 dtype, it doesn't affect the display in pandas or for matplotlib, so the correct method is above.
However, you could generate date strings using dt.strftime to add a column of desired date strings but this gives you a column of strings which is not as useful in my opinion:
In [39]:
df['DateStrings'] = df['DateTime'].dt.strftime('%Y-%m-%d %H:%M:%S')
df

Out[39]:
             DateTime  Value          DateStrings
0 2016-05-17 22:50:27   1914  2016-05-17 22:50:27
1 2016-05-17 22:55:27   1597  2016-05-17 22:55:27
2 2016-05-17 23:00:27   1429  2016-05-17 23:00:27
3 2016-05-17 23:05:27   1462  2016-05-17 23:05:27
4 2016-05-17 23:10:27   2038  2016-05-17 23:10:27

this results in the plot:
df.plot(x='DateStrings', y='Value')
plt.show()

You can see though that the x-axis labels are duff, you'd need to rotate them which is handled automatically using the former method

