こんにちは、
数値と多くの null 値 (おそらく 70-80% null) を持つ列 A (約 15,000 行) があります。
行 i で次の平均に等しい列 B を作成したいと思います: *A からの最後の 10 個の非 null 値*
--> これは、 A[row i-1] 、 A[row i-2]、... を取り、10 個の非 null 値が得られるまで戻ることを意味します (または、行 1 に到達した場合は、任意の数 <= 10 を取ります)取得する null 以外の値)
また、平均に加えて、中央値とモードも実行したいと思いますが、モードの平滑化されたバージョンは次のとおりです。
まず、10 個の非 null 値のガウス平滑化を行い、その分布の argmax (モード) を取得します。
考えや提案をありがとう!
***
ソリューションのアイデア: 最後の 10 個の非 null 値を使用していくつかの異なる計算を実行したいので、最初に、最後の 10 個の非 null 値に等しい配列をエントリとする列 C を作成する必要があるため、私が考えたのは 1 つです。列 C を操作して B1 (平均)、B2 (中間)、B3 (平滑化モード) を生成する 3 つの数式を実行できます。
この列 C の配列の構築に向けて進んでいるコードの一部を次に示します。
//step 1 grab the last say 50 entries (some fixed amount that will likely have 10 non-nulls)
For Each Row( dt_join,
to = Row();
If( to - 50 < 0,
from = 1,
from = to - 50); // Quantile( 0.5,
values = :away_1g_pull_seconds[Index( From, To )] < 50, Break());
);
//step 2 convert array to list, drop nulls, convert list of first 10 entries back to array ...
//I don't know how to assign this to a row of C
num_lag = 10;
values = dt_join:A[Index( From, To )] ;
MyList = Remove(as list(values)[1], as list(Loc(as list(values)[1], .)) ); //convert array to list and remove nulls
Mat = Number Col Box("", MyList[1:10]) << get as matrix; //hack convert to array