Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何更新数据帧中的所有值?_C#_Deedle - Fatal编程技术网

C# 如何更新数据帧中的所有值?

C# 如何更新数据帧中的所有值?,c#,deedle,C#,Deedle,我想替换数据帧/系列中的所有值; 例如,我想用0替换所有的-1 我找不到做这件事的方法。在F中,似乎有一个mapValue函数,但在C中找不到等效函数 void cleanupDF(Frame<int, string> df) { foreach(string c in new string[] {"col1","col2" }) { var relabeled = df.Columns[c].Select(kvp => ((int)kvp.Value

我想替换数据帧/系列中的所有值; 例如,我想用0替换所有的-1


我找不到做这件事的方法。在F中,似乎有一个mapValue函数,但在C中找不到等效函数

 void cleanupDF(Frame<int, string> df) {
    foreach(string c in new string[] {"col1","col2" }) {
        var relabeled = df.Columns[c].Select(kvp => ((int)kvp.Value ==- 1 ? 0 : (int)kvp.Value));
        df.ReplaceColumn(c, relabeled);
    }
}
在整个帧类型上还有一个Select方法,因此您应该能够编写类似这样的内容,尽管我没有测试过:

var res = df.Select((int row, string col, double v) => v == -1 ? 0 : v);