2024-09-30 08:38:12 发布
网友
我有一个大的时间序列(熊猫数据帧)的风速(10分钟平均),其中包含错误数据(死传感器)。如何自动标记。我试着用移动平均法。 一些其他方法,然后移动平均线是非常赞赏。我已附上下面的样本数据图像
有几种方法可以解决这个问题。我先来谈谈分歧:
%matplotlib inline import pandas as pd import numpy as np np.random.seed(0) n = 200 y = np.cumsum(np.random.randn(n)) y[100:120] = 2 y[150:160] = 0 ts = pd.Series(y) ts.diff().plot();
下一步是找出连续零的打击有多长
def getZeroStrikeLen(x): """ Accept a boolean array only """ res = np.diff(np.where(np.concatenate(([x[0]], x[:-1] != x[1:], [True])))[0])[::2] return res vec = ts.diff().values == 0 out = getZeroStrikeLen(vec)
现在,如果len(out)>0,你可以断定有问题。如果你想更进一步,你可以看看this。它在R中,但在Python中复制并不难
len(out)>0
有几种方法可以解决这个问题。我先来谈谈分歧:
下一步是找出连续零的打击有多长
现在,如果
len(out)>0
,你可以断定有问题。如果你想更进一步,你可以看看this。它在R中,但在Python中复制并不难相关问题 更多 >
编程相关推荐