やあ、
データ テーブルには多数の数値列があり、そのすべてに欠損値があります。
それらのいくつかだけを選択し (列名が既にわかっていることを考慮して)、欠落している値をゼロに置き換えたいと考えています。
以下のようにコードを書いたのですが、うまくいきません。
手伝ってくれる?
ありがとう!
dt = data table("Untitled 9");
col_list = {"A","B"};
For( i = 1, i <= N Items( col_list ), i++,
col_list[i][dt << get rows where( Is Missing( col_list[i][]) )] = 0);過去に検索/置換オプションを使用しました:
欠落をゼロに置き換えたい列を選択します
検索する 。 「選択した列のみを検索」オプションを必ずチェックしてください。
私の方法はすべての欠損値を置き換えます数値列。 特定のリストの値を置き換えたいだけの場合は、指定するだけです
col_list = {"A", "B"}
col_list の私の定義の代わりに。
これを行う1つの方法は次のとおりです。
dt = New Table( "Test Zeroes", Add Rows( 3 ),
New Column( "Column 1", Character, "Nominal", Set Values( {"a", "b", "c"} ) ),
New Column( "Column 2", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [1, ., 3] ) ),
New Column( "Column 3", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [., 2, .] ) )
);
col_list = dt << get column names(string, numeric);
For( i = 1, i <= N Items( col_list ), i++,
missing_rows = dt << get rows where (is missing(as column(dt, col_list[i])));
if (nrows(missing_rows) > 0,
column(dt, col_list[i])[missing_rows] = 0;
);
);