question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: unequally spaced timeseries

See original GitHub issue

First, big thanks for a nice library! Very useful!

I am trying to follow your Quick Start for SeasonalAD, but I am encountering a problem. My timeseries seem be to unequally spaced (e.g. 09:05, 09:15, 9:30, 9:55). Hence the SeasonalAD complains: RuntimeError: Series does not follow any known frequency (e.g. second, minute, hour, day, week, month, year, etc. How to overcome this? I have tried rounding my series to 15min, removing duplicates and resampling.

s_train.index = s_train.index.round('15min')
s_train = s_train[~s_train.index.duplicated()]
s_train = s_train.asfreq('15min')

Obviously nothing worked. Any ideas how to solve this? I wish to retain as much granularity as possible.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
zhj0513commented, Dec 24, 2020

try s_train.resample(‘15min’).ffill() if adtk.data doesn’t have resample

1reaction
tailaiwcommented, Feb 4, 2020

@ajdapretnar Seasonal decomposition in ADTK requires the input follows equally spaced time series, as you noticed. Therefore, the time series should be resampled with a constant frequency, for example 15 min.

If you got a ValueError regarding NaN values, the reason is that your resampling may introduce NaN value to the new time series (in your example, 9:45 will have NaN value). Currently, SeasonAD does not support time series with NaN, unless the NaN values are on the starting or ending part of the time series and they will be ignored.

In the adtk.data module, we offer a resample function, which resamples a time series with user-given space. The resampling is based on linear interpolation. You may try it like the follows.

from adtk.data import resample
s_train = resample(s_train, dT="15 min")

If you want to fill NaN with forward or backward filling instead of interpolation, I believe you can also use the fillna method of Pandas.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any gold standard for modeling irregularly spaced ...
If the observations of a stochastic process are irregularly spaced the most natural way to model the observations is as discrete time ......
Read more >
uneven spaced time series - MathOverflow
The times series are uneven spaced, that is tk−tk−1 is not independent of k. I don't know of any textbook, algorithm or paper...
Read more >
Unevenly spaced time series - Wikipedia
spaced time series is a sequence of observation time and value pairs (t n, X n ) in which the spacing of observation...
Read more >
On Unequally Spaced Time Points in Time Series
This article discusses the sampling of stationary discrete-time stochastic processes at fixed but unequally spaced time points. The pattern of the sampling ...
Read more >
Unevenly Spaced Data | ideo.com
These event-triggered sensors give rise to unevenly-spaced time series. Many analysts will immediately convert unevenly-spaced data to evenly-spaced time ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found