数据清理(标记)死机传感器

2024-09-30 08:38:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个大的时间序列(熊猫数据帧)的风速(10分钟平均),其中包含错误数据(死传感器)。如何自动标记。我试着用移动平均法。 一些其他方法,然后移动平均线是非常赞赏。我已附上下面的样本数据图像

enter image description here


Tags: 数据方法标记图像错误时间序列传感器
1条回答
网友
1楼 · 发布于 2024-09-30 08:38:12

有几种方法可以解决这个问题。我先来谈谈分歧:

%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();

enter image description here

下一步是找出连续零的打击有多长

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中复制并不难

相关问题 更多 >

    热门问题