Review of Polygot Notebooks

Polygot notebooks are a fanastic way to do data science. They allow you to use multiple languages in a single notebook. My personal preference is the vs code extension formerly .net interactive offered as a vs code extension.
Using the code from https://towardsdev.com/how-to-rank-software-engineers-using-bash-c8b1bd8885fb,
I can grab the data from the CSV file and put it into a list of strings.
using System.IO;using System.Linq;using System.Globalization;using CsvHelper;using System;
// Read data from CSV filevar records = new List<dynamic>();using (var reader = new StreamReader("data/changes_by_file.csv"))using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)){ records = csv.GetRecords<dynamic>().ToList();}
// Extract data for chartvar counts = records.Select(r => r.Count);var file = records.Select(r => r.File);
// export authors as list of stringvar countsList = counts.ToList();// get value from countsvar fileList = file.ToList();The script reads data from a CSV file located at “data/changes_by_file.csv” using CsvHelper library to parse the CSV file. It creates a list of dynamic objects where each object represents a row in the CSV file.
After reading the data, it extracts two columns from the CSV file: “Count” and “File” by projecting them into separate lists using Linq.
Finally, it exports the counts list and file list as separate variables called countsList and fileList, respectively, by converting them to a list using ToList() method.
#!share --from csharp countsList#!share --from csharp fileListopen Plotly.NETlet intList = countsList |> Seq.cast<string> |> List.ofSeq |> List.map System.Double.ParseintList |> List.map (fun x -> double x)let newKeys = fileList |> Seq.cast<string> |> List.ofSeqlet column = Chart.Column(values = intList, Keys = newKeys)columnThe script above first loads the Plotly.NET package and then performs some data manipulation and plotting.
The script uses the shared variables “countsList” and “fileList” from a C# notebook (using the #!share magic command) to create a column chart using the Plotly.NET library.
First, it converts the countsList from a list of strings to a list of doubles using Seq.cast
Then, it creates a new list called newKeys by casting the fileList to a list of strings.
Next, it creates a new column chart using the Chart.Column method of the Plotly.NET package. It passes in the values from the intList and keys from the newKeys list.
Finally, the column object is displayed in the output.
Conclusion
Section titled “Conclusion”Overall polyglot notebooks can be fairly good for data science, do not recommend using the C# bindings Plotly.NET for data science, and prefer using F# for data science.
More content like this is available in my book on amazon kdp.
© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js
