4

I am a newbie to C#/F#. There are very limited online resources demonstrating Deedle in C#, but I do need to use C# to conduct data analysis.

The sample data is Titanic.csv, from here: https://forge.scilab.org/index.php/p/rdataset/source/tree/master/csv/datasets/Titanic.csv

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using Deedle;

namespace DepositDataCleaning
{
    class Program
    {
        static void Main(string[] args)
        {

    var titanic = Frame.ReadCsv(@"Titanic.csv");
    DataTable dt = titanic.ToDataTable(new string[1]{"Index"}); 
    # This works, to convert a deedle frame to .NET DataTable Format

    var new_deedleframe = Frame.FromRecords(dt); # it doesn't work.

        }
    }
}
chl111
  • 468
  • 3
  • 14

2 Answers2

3

You can convert the DataTable to a DataTableReader and use Frame.ReadReader to create the Frame:

var new_deedleframe = Frame.ReadReader(dt.CreateDataReader())
Talmage
  • 343
  • 1
  • 11
-1

You need a collection for Frame.Records. A DataTable isn't a collection, but its Rows member is. You can do this:

var deedleFrame = Frame.FromRecords(dt.Rows.OfType<DataRow>());
Rob Lyndon
  • 12,089
  • 5
  • 49
  • 74
  • This is wrong. Frame.FromRecords performs reflection over the properties of the objects passed in. If you do what you suggested, it'll create a Frame out of the properties on a DataRow, not the items within it. – MgSam Feb 27 '17 at 19:55
  • @MgSam You are right. Would you mind sharing any other solutions to my problem? – chl111 Apr 06 '17 at 17:42