C#.NET中的Pandas Dataframe或类似版本 [英] Pandas Dataframe or similar in C#.NET
问题描述
我目前正在实现早期用Python构建的Gurobi线性程序模型的C#版本.我有许多CSV文件,从中导入数据并创建pandas数据框,并且从这些数据框中获取列以创建在线性程序中使用的变量.使用数据框创建变量的python代码如下:
I am currently working on implement the C# version of a Gurobi linear program model that was earlier built in Python. I have a number of CSV files from which I was importing the data and creating pandas dataframes, and I was fetching columns from those dataframes to create variables that I was using in my Linear Program. The python code for creating the variables using dataframes is as follows:
dataPath = "C:/Users/XYZ/Desktop/LinearProgramming/TestData"
routeData = pd.DataFrame.from_csv(os.path.join(dataPath, "DirectLink.csv"), index_col=None)
#Creating 3 Python-dictionaries from Python Multi-Dict using column names and keeping RouteID as the key
routeID, transportCost, routeType = multidict({x[0]:[x[1],x[2]] for x in routeData[['RouteID', 'TransportCost','RouteType']].values})
示例:如果csv结构如下:
Example: If the csv structure is as follows:
RouteID RouteEfficiency TransportCost RouteType
1 0.8 2.00 F
2 0.9 5.00 D
3 0.7 6.00 R
4 0.6 3.00 T
3个变量应为:路线ID:1 2 3 4
The 3 variables should be: RouteID: 1 2 3 4
TransportCost:
TransportCost:
1:2.00
2:5.00
3:6.00
4:3.00
RouteType:
RouteType:
1:F
2:D
3:R
4:T
现在,我想创建上述代码的C#版本来执行相同的任务,但是我了解到C#不支持数据帧.我尝试寻找一些替代方法,但找不到任何东西.请帮助我.
Now, I want to create a C# version of the above code that does the same task, but I learnt that C# doesn't support dataframes. I tried looking for a few alternatives, but am unable to find anything. Please help me with this.
推荐答案
Deedle
是一个处理DataFrame的.Net库.
Deedle
is a .Net library that handles DataFrames.
http://bluemountaincapital.github.io/Deedle/index.html
这篇关于C#.NET中的Pandas Dataframe或类似版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!