Create .ipynb file using selwct .net Enviroment and select C# in cell for execution

Import nuget package

1
#r "nuget: Microsoft.Data.Analysis" 

Import namespace

1
2
3
using System;
using System.Collections.Generic;
using Microsoft.Data.Analysis;

Create class

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
public class RedirectEntry
{
    public string WebsiteUrl { get; set; }
    public string RedirectUrl { get; set; }
    public string Status => IsValid ? "✅" : "❌";
    public bool IsValid { get; set; }
}

var data = new List<RedirectEntry>
{
    new RedirectEntry
    {
        WebsiteUrl = "https://codefrydev.in/Updates",
        RedirectUrl = "https://codefrydev.in/",
        IsValid = true
    },
};

Create Generic Function for anytype of list incection

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
DataFrame ShowTable<T>(List<T> items)
{
    var properties = typeof(T).GetProperties();
    List<DataFrameColumn> columns = new();

    foreach (string header in properties.Select(p => p.Name))
    {
        columns.Add(new StringDataFrameColumn(header, new List<string>())); // Read as string
    }
    foreach(var item in items)
    {
        for (int i = 0; i < properties.Length; i++)
        {
            var values = properties.Select(p => p.GetValue(item)?.ToString() ?? "").ToList();
            ((StringDataFrameColumn)columns[i]).Append(values[i]);
        }
    }
    return new DataFrame(columns);
}

Simply call the function in next cell without any commas or stuff

1
ShowTable(data)