At the moment Pandas doesn’t have a nice capabiliy to take moving averages of time series with irregular gaps, especially with the time data isn’t in datetime format. The traces library does. I’ll demonstrate with an example from Ciw.
Consider an M/M/c queue with a server schedule of 1 server for three days, and 2 servers for four days, running for four years:
Here a state tracker is used to track the systems state over time. It records the entire history of the state changes, that is an irregularly spaced time-series:
Plotting this doesn’t give us much insight, as it’s too stochastic:
The traces library let’s us take moving averages over this irregular time series, with any window size we want, e.g. a 7-day moving average, 30-day moving average, or a quarterly moving average:
This gives us something more interpretable:
The traces library also allows us to do this from file, which I think is a bit nicer:
When taking a moving average we can return a pandas Series, which makes this nice and compatible with other analyses too. This library is much nicer than my previous soluiton of converting to datetime and back!