Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas Dataframe or similar in C#.NET

Tags:

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.

like image 956
Amit Madan Avatar asked Apr 27 '18 15:04

Amit Madan


People also ask

What is the difference between pandas and Dataframe?

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.

How do you know if two DataFrames are similar?

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.


2 Answers

Deedle is a .Net library that handles DataFrames.

http://bluemountaincapital.github.io/Deedle/index.html

like image 185
edeboursetty Avatar answered Oct 31 '22 03:10

edeboursetty


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 :)

like image 34
Lucas Araujo Avatar answered Oct 31 '22 05:10

Lucas Araujo