Building TimeDeltas in Pandas

I am trying to build timedeltas on the x axis, but I see strange behavior. With the following code, I would expect two graph curves:

dates = [datetime.datetime(2013,1,1) + datetime.timedelta(seconds=x**2) for x in range(1000)]
deltas = [datetime.timedelta(seconds=x**2) for x in range(1000)]
values = range(1000)
foo = DataFrame.from_dict({'dates': dates, 'deltas': deltas, 'vals': values})
foo.plot(x='dates', y='vals')
foo.plot(x='deltas', y='vals')

but in fact the second graph comes out as a straight line, since in this case the x axis is scaled. Is this a mistake or am I just doing it wrong?

enter image description here

+4
source share
1 answer

It is not supported by matplotlib ATM, so see this problem here

The workaround is quite simple, just set the index to a formatted (lowercase version) and it will work.

+2
source

All Articles