Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle non-equidistant data gracefully #25

Open
ecomodeller opened this issue Mar 9, 2021 · 0 comments
Open

Handle non-equidistant data gracefully #25

ecomodeller opened this issue Mar 9, 2021 · 0 comments

Comments

@ecomodeller
Copy link
Member

>>> from datetime import datetime
>>> import pandas as pd
>>> from anomalydetection.detectors import DiffRangeDetector
>>>
>>> dates = [
...     datetime(2000,1,1),
...     datetime(2000,1,2),
...     datetime(2000,1,7)]
>>>
>>> normal_data = pd.Series([0.0,0.5,0.0])
>>> normal_data.index = dates
>>>
>>> df_detector = DiffRangeDetector()
>>>
>>> df_detector.fit(normal_data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\users\jan\code\anomalydetection\anomalydetection\detectors.py", line 155, in fit
    data_diff = self.diff_time_series(data)
  File "c:\users\jan\code\anomalydetection\anomalydetection\detectors.py", line 147, in diff_time_series
    time_diff = data.index.shift() - data.index
  File "C:\Users\JAN\Miniconda3\lib\site-packages\pandas\core\indexes\datetimelike.py", line 532, in shift
    result = arr._time_shift(periods, freq=freq)
  File "C:\Users\JAN\Miniconda3\lib\site-packages\pandas\core\arrays\datetimelike.py", line 1148, in _time_shift
    raise NullFrequencyError("Cannot shift with no freq")
pandas.errors.NullFrequencyError: Cannot shift with no freq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant