README.md: better downsampling code
This commit is contained in:
parent
5bf6236fab
commit
7b93a93e5f
@ -32,9 +32,12 @@ import pandas as pd
|
|||||||
# assuming the time series are stored in a tab seperated file, where `time` is
|
# assuming the time series are stored in a tab seperated file, where `time` is
|
||||||
# the name of the column containing the timestamp
|
# the name of the column containing the timestamp
|
||||||
df = pd.read_csv(filename, sep="\t", index_col='time', parse_dates=True)
|
df = pd.read_csv(filename, sep="\t", index_col='time', parse_dates=True)
|
||||||
df = df.fillna(method="bfill", limit=1e9)
|
# use a meaningful sample size depending on how the frequency of your time series:
|
||||||
# drop rows with the same time stamp
|
# Higher is more accurate, but if series gets too long, the calculation gets cpu and memory intensive.
|
||||||
df = df.groupby(level=0).first()
|
# Keeping the length below 2000 values is usually a good idea.
|
||||||
|
df = df.resample("500ms").mean()
|
||||||
|
df.interpolate(method="time", limit_direction="both", inplace=True)
|
||||||
|
df.fillna(method="bfill", inplace=True)
|
||||||
```
|
```
|
||||||
|
|
||||||
- kshape also expect no time series with a constant observation value or 'n/a'
|
- kshape also expect no time series with a constant observation value or 'n/a'
|
||||||
|
@ -7,8 +7,6 @@ from numpy.linalg import norm
|
|||||||
from numpy.fft import fft, ifft
|
from numpy.fft import fft, ifft
|
||||||
|
|
||||||
|
|
||||||
#from scipy.linalg import eigh
|
|
||||||
|
|
||||||
def zscore(a, axis=0, ddof=0):
|
def zscore(a, axis=0, ddof=0):
|
||||||
a = np.asanyarray(a)
|
a = np.asanyarray(a)
|
||||||
mns = a.mean(axis=axis)
|
mns = a.mean(axis=axis)
|
||||||
|
Loading…
Reference in New Issue
Block a user