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})
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
The 3 variables should be: RouteID: 1 2 3 4
TransportCost:
1:2.00 2:5.00 3:6.00 4:3.00
RouteType:
1:F 2:D 3:R 4:T
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.
A pandas dataframe is a two-dimensional data-structure that can be thought of as a spreadsheet. A dataframe can also be thought of as a combination of two or more series. In the code example above, a dataframe is initialized using two different lists of values and one list of keys/indexes.
DataFrame - equals() function The equals() function is used to test whether two objects contain the same elements. This function allows two Series or DataFrames to be compared against each other to see if they have the same shape and elements.
Deedle
is a .Net library that handles DataFrames.
http://bluemountaincapital.github.io/Deedle/index.html
New kid on the block
https://devblogs.microsoft.com/dotnet/an-introduction-to-dataframe/
Announced today, still in preview, Microsoft's own take on a DataFrame :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With