linkedin / luminol

Anomaly Detection and Correlation library
Apache License 2.0
1.19k stars 217 forks source link

Pandas Support #36

Open tylerwmarrs opened 6 years ago

tylerwmarrs commented 6 years ago

I am interested in your module, however I noticed that it doesn't support Pandas dataframes out of the box. Would you mind explaining the reasoning behind this? Also - I could potentially add this capability. However, I am trying to understand any potential pitfalls.

Thanks in advance. Great work.

RiteshMaheshwari commented 6 years ago

No pitfalls that I can think of. Feel free to add this.

dipanjanS commented 6 years ago

I think we need this, especially if I want to leverage pandas timeseries (Series) objects. Right now facing issues trying to get my time series objects into the APIs from this library. Any good documentation available for the time being? The default one doesn't seem exhaustive enough.

tylerwmarrs commented 6 years ago

@dipanjanS Here is a code snippet that transforms a pandas time series to a luminol time series. I hope it helps.

import pandas as pd
import numpy as np
import luminol
from luminol.modules.time_series import TimeSeries
from luminol.utils import to_epoch

# generate random time series in pandas
rng = pd.date_range('1/1/2011', periods=72, freq='H')
ts = pd.Series(np.random.randn(len(rng)), index=rng)

# transform index values to epoch time
ts.index = ts.index.map(lambda d: to_epoch(str(d)))
lts = TimeSeries(ts.to_dict())