Skip to content
Advertisement

Plot elapsed time on x axis using date indexed time-series data

In my pandas dataframe, my time series data is indexed by absolute time (a date of format YYYY-MM-DD HH24:MI:SS.nnnnn):

JavaScript

How can I plot this data such that the x-axis of my plots is an increasing value of some interval of seconds (e.g, “0 10 20 30 40 50”) relative to the timestamp of my first sample ? Do I need to use a Period, or convert to a frequency using asfreq() ? Or should I be using a DateFormatter ?

The documentation is a bit confusing and there don’t seem to be any good examples – most of the time series examples seem to revolve around coarse intervals such as months or years.

Advertisement

Answer

You can convert your datetimeindex to a timedeltaindex and then plot.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement