C# Deedle AggregateRowsBy/PivotTable 示例
C# Deedle AggregateRowsBy/PivotTable Examples
我是 C#/F# 的新手。演示如何使用 C# 中的 Deedle 按组聚合数据的在线资源非常有限。 F# 格式不能直接应用于 C#。
数据是Titanic.csv,来自这里:
https://forge.scilab.org/index.php/p/rdataset/source/tree/master/csv/datasets/Titanic.csv
var titanic = Frame.ReadCsv(@"Titanic.csv");
#How to proceed, to get the sum of Column Freq?
var res = titanic.AggregateRowsBy<string,string>("Sex","Age",...);
#or
var res = titanic.PivotTable<string,string>("Sex","Age",...);
任何简单的例子都会很有帮助。谢谢!
我想我明白你想要得到什么。 C# 代码如下:
Frame<string, string> res =
titanic.PivotTable<int, string, string, string, int>
("Sex", "Age", x => x.GetColumn<int>("Freq").NumSum());
对于您的文件,我得到以下结果:
Child Adult
Male -> 64 1667
Female -> 45 425
我是 C#/F# 的新手。演示如何使用 C# 中的 Deedle 按组聚合数据的在线资源非常有限。 F# 格式不能直接应用于 C#。
数据是Titanic.csv,来自这里: https://forge.scilab.org/index.php/p/rdataset/source/tree/master/csv/datasets/Titanic.csv
var titanic = Frame.ReadCsv(@"Titanic.csv");
#How to proceed, to get the sum of Column Freq?
var res = titanic.AggregateRowsBy<string,string>("Sex","Age",...);
#or
var res = titanic.PivotTable<string,string>("Sex","Age",...);
任何简单的例子都会很有帮助。谢谢!
我想我明白你想要得到什么。 C# 代码如下:
Frame<string, string> res =
titanic.PivotTable<int, string, string, string, int>
("Sex", "Age", x => x.GetColumn<int>("Freq").NumSum());
对于您的文件,我得到以下结果:
Child Adult
Male -> 64 1667
Female -> 45 425