1

I am dealing with data from sensors. Sometimes these sensors have blackouts and brownouts, in consequence I can have the following kind of Time Series in a Frame, let's call it "myData":

[7.438984; 0,000002; 7.512345; 0.000000; 7.634912; 0.005123; 7.845627...]

Because I need only 3 decimals precision, I rounded the data from the frame:

var myRoundedData = myData.ColumnApply((Series<DateTime, double> numbers) => numbers.Select(kvp => Math.Round(kvp.Value, 3)));

I get the columns from the frame and filtered the Zeros "0.000":

var myFilteredTimeSeries = from kvp in myTimeSeries where kvp.Value != 0.000 select kvp;

So, my Time Series is partially filtered: [7.439; 7.512; 7.635; 0.006; 7.846...]

However, the value "0.006" is not valid!

How could I implement an elegant filtering syntax based on the previous value, something like a "percent limit" in the rate of change:

if (0.006 / 7.635) * 100 < 0.1 then ---> drop / delete(0.006)

4

2 回答 2

1

如果您只想查看上一个/下一个值,则可以将系列移动一个并将其与原始值一起压缩。这将为您提供一系列对(一个值与上一个/下一个值一起):

var r = actual.ZipInner(actual.Shift(1));

如果要查看指定元素周围的更多元素,则需要 Deedle 提供的窗口函数之一:

最简单的示例是用于WindowInto获取一个值以及它之前的 4 个值:

var res = values.WindowInto(5, win => 
   // 'win' is a series with the values - do something clever here! 
);
于 2015-07-08T14:08:21.827 回答
1

关键之一是专注于涉及价值及其“邻域”的方法,就像@tomaspetricek 之前指出的那样(谢谢!)。我的目标是找到一个“无噪音”时间戳或键来构建框架并执行 AddColumn 操作,这本质上是 JoinKind.Left 操作。

为了解决这个问题,我使用了 Pairwise() 方法来关注“Item1”(当前值)和“Item2”(下一个值),如下所示:

double filterSensibility = 5.0 // % percentage

var myBooleanFilteredTimeSeries = myTimeSeries.Pairwise().Select(kvp => (kvp.Value.Item2 / kvp.Value.Item1) * 100 < filterSensibility);

在这里我可以写出我想要的关系!(见问题)然后根据我得到之前发布的时间序列(示例):

myBooleanFilteredTimeSeries = [FALSE; 错误的; 错误,正确;错误的...]

TRUE 表示该值有噪声!所以我只得到 FALSE 布尔值:

 var myDateKeysModel = from kvp in myBooleanFilteredTimeSeries where kvp.Value == false select kvp;

我从最后一个时间序列创建了一个框架:

myCleanDateTimeKeysFrame = Frame.FromRecords(myDateKeysModel);

最后,我将原始(嘈杂)时间序列添加到先前创建的帧中:

myCleanDateTimeKeysFrame.AddColumn("Column Title", myOrginalTimeSeries);

......等等瞧!

在此处输入图像描述

于 2015-07-14T09:37:05.443 回答