Pandas
跳转到导航
跳转到搜索
常见数据操作
加载时间序列数据
ts = pd.Series(
d['data'],
index = pd.date_range(
datetime.fromtimestamp(d['start']),
datetime.fromtimestamp(d['end']-1),
freq = '%ss' % d['step'],
)
)
滑动平均
ts.rolling(window=10).mean()
删除异常数据
def de_rare(ts, threshold=0.001):
counts = ts.value_counts(normalize=True)
return ts[ts.isin(counts[counts > threshold].index)]