I have a pandas dataframe which contains a column called "order.timestamp" - a list of timestamps for a set of occurrences.
I would like to plot these timestamps on the x-axis of a matplotlib plot and have the dates, hours, seconds etc display as I zoom in. Is this possible?
I have tried using datetime.strptime:
date_format = '%Y-%m-%dT%H:%M:%S.%fZ'
for i in range(0, len(small_data)) :
b = datetime.strptime(small_data["order.timestamp"].iloc[i],date_format)
small_data = small_data.set_value(i, "order.timestamp", b)
Which re-creates the column "order.timestamp" in my pandas dataframe. The column now contains entries like:
2017-01-01 12:50:06.902000
However, if I now try to plot as normal:
fig = plt.figure()
plt.plot(small_data["order.timestamp"], small_data["y_values"])
plt.show()
I see an error
ValueError: ordinal must be >= 1
Any help greatly appreciated!