Polyglot Notebooks review: sharing data between C# and F# cells

Polyglot Notebooks are a great way to do data science in .NET. You can use several languages in one notebook and pass variables between them. My preference is the VS Code extension (formerly .NET Interactive Notebooks).
Reading a CSV in C#
Section titled “Reading a CSV in C#”Using the data from How to rank software engineers using Bash, this C# cell reads a CSV of change counts per file into two lists:
#r "nuget: CsvHelper"
using System.Globalization;using System.IO;using CsvHelper;
List<dynamic> records;using (var reader = new StreamReader("data/changes_by_file.csv"))using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)){ records = csv.GetRecords<dynamic>().ToList();}
// Each dynamic record exposes the CSV headers as properties (values are strings)var countsList = records.Select(r => r.Count).ToList();var fileList = records.Select(r => r.File).ToList();CsvHelper’s dynamic records turn each row into an object whose properties are the header names, so the CSV needs Count and File columns.
Charting it in F#
Section titled “Charting it in F#”#!share copies a variable from another kernel into the current one. This F# cell pulls in both lists and draws a column chart with Plotly.NET:
#r "nuget: Plotly.NET.Interactive"#!share --from csharp countsList#!share --from csharp fileList
open Plotly.NET
let counts = countsList |> Seq.cast<string> |> Seq.map System.Double.Parse |> List.ofSeqlet files = fileList |> Seq.cast<string> |> List.ofSeq
Chart.Column(values = counts, Keys = files)The lists arrive as collections of object, so Seq.cast<string> restores the type before the counts are parsed into numbers. Plotly.NET.Interactive makes the chart render inline as the cell output.

Verdict
Section titled “Verdict”Polyglot Notebooks can be fairly good for data science. I don’t recommend using Plotly.NET from C#; F# is the better fit for this kind of work.
More content like this is in my book on Amazon KDP.
© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)
