Aprende conmigo — Learn With Me · C# · Data analysis
A scalpel for your data: real-life data analysis with C# and Squirrel
Your electricity bills, your bank statement, last quarter's sales at the shop: nearly everything you want to understand fits on a laptop. You don't need a cluster, and you don't need to switch languages. You need a precise tool inside the C# you already write every day.
The pantry: every acorn is a row. The dashed gaps are missing values, and deciding what to do about them is part of the job.
Contents
The kitchen-table question
Picture a family that wants to know how its electricity use has changed over the years. Measuring a whole city would be a serious engineering project. Measuring one household over a decade gives you roughly 120 rows, one per monthly bill. That is the example Sudipta Mukherjee, author of Data Analytics with C# and creator of the Squirrel library, uses to define small data: human-scale data that fits in a laptop's memory and answers questions that make daily life better.
The book draws the contrast sharply. Big data can show that millennials lean toward sustainable fashion; small data can explain why Sarah, a 28-year-old software engineer in Seattle, sent back her last three orders. One is the aerial footage of a city. The other is the driver who crosses it every day and knows to avoid Fifth Avenue on Thursdays, because that's farmers' market day.
The valuable question is rarely "what do millions of people do?" It's "what is going on here, with my stuff?"
Scott Hanselman makes the same point in the book's first foreword. Most developers don't wake up wanting to do data science. They want to know why sign-ups dipped, which customers are churning, or which feature nobody touches. Those questions live close to the code, and answering them shouldn't require a new language or a new mindset.
How big is your data, really?
Both the book and the Squirrel README borrow Professor Alex Smola's naming scheme for dataset sizes: tiny fits on your phone, small fits on your laptop (1 GB), medium fits on a workstation (4 GB), large needs a server, and big is when your server clusters start to struggle. The book deliberately stays in the tiny-to-medium range.
To make that concrete, Mukherjee estimates CSV sizes for familiar situations. A transaction log with 100,000 rows and 10 columns is about 20 MB. Fifty thousand customer feedback records with 15 columns come to about 30 MB. Five million e-commerce sales rows land near 750 MB. By industry, a single clinic's patient records (50,000–100,000 rows) count as tiny, while a regional hospital department (1–2 million rows) counts as small.
Calculator: how big is your dataset?
Tool 1The book's assumptions: 20 characters per text value, 8 bytes per number, 10 characters per date and 2 bytes of CSV overhead per field. The 1 GB and 4 GB limits come from Smola's scale; the 100 MB "tiny" cutoff and the 512 GB "large" cutoff are editorial assumptions for this demo.
Try it with your own numbers. Most of the time, the dataset that keeps you up at night weighs a few megabytes.
A scalpel, not a sledgehammer: why C#
Brad Jolicoeur, a principal architect with more than twenty years in the field, wrote the book's second foreword. His summary gave this article its title:
"For most problems, we don't need a sledgehammer; we need a scalpel." — Brad Jolicoeur, foreword
Sales for a coffee shop, churn for a SaaS product, errors buried in log files: these are too big for a spreadsheet and far too small to justify big-data infrastructure. And the scalpel has to work inside the tools you already know.
So why not just learn Python? Chapter 1 answers with the economics of software. According to the figures the book cites:
~75%
of a developer's time goes into debugging and reading code to understand it.
10×
longer to read code than to write it.
40–80%
of total software cost is typically maintenance.
The author's point: the few milliseconds a "faster" language might save are small change next to the hours saved when code is readable at a glance, type-checked, debuggable in your IDE and living right next to your application. If your team already speaks C#, your analysis can speak it too.
These are industry statistics as reported in the book; it does not list their original sources.
Meet Squirrel
Squirrel is an open-source library (MIT license) built on .NET Standard 2.0 and modern .NET. It is named after the squirrel's agility, and the author is specific about what "agile" means here: not execution speed, but how fast you, the developer, can produce the analysis. Data pipelines in minutes, not days.
The essentials in five ideas
The package has another name
On NuGet you install TableAPI, but in code you write using Squirrel;.
Everything is a Table
Each row is a dictionary of strings (Dictionary<string,string>), so any CSV loads without a schema fight.
Immutable and chainable
Loading, cleaning and slicing always return a new table, which means less state to track in your head.
Hybrid typing
Start loose, project with LINQ into anonymous types or RecordTable<T> when you're ready, and come back with ToTableFromAnonList().
Reads like the business
RemoveOutliers, NormalizeColumn, TopNPercent: the names say what they do.
Your first console app in four steps
// 1. Create the project and add the package
dotnet new console -n MyData
cd MyData
dotnet add package TableAPI
// 2-4. In Program.cs: import, load, look
using Squirrel;
var power = DataAcquisition.LoadCsv("power_bills.csv");
power.PrettyDump();
PrettyDump() prints a formatted table to the console. It's the quickest way to confirm that what you loaded is what you thought you loaded.
Squirrel, Microsoft's DataFrames, or pandas?
Best for: ETL, data cleaning, business rules and quick reporting. Style: fluent method chains that read almost like a spec. Extras: first-class cleaning (normalize, mask, outliers) and built-in HTML charts through Google Charts or Chart.js. Types: hybrid, dynamic on load and strong when you project.
Best for: high-performance ML.NET pipelines and millions of rows where memory layout matters. Style: object-oriented DataFrame work with more boilerplate. Types: strictly columnar. Charts: external libraries. That is how Brad Jolicoeur sums it up after building proofs of concept with both.
Best for: the de facto standard for data wrangling in Python. Squirrel aims to give C# developers that experience with a home-court advantage: instead of learning pandas' boolean masking, you use LINQ, which you already know. If your team lives in Python, pandas remains the natural choice.
The four layers
Squirrel suggests solving any analysis problem the way a data scientist would, by stacking layers: acquire the data, cleanse and model it, slice and dice it, then show it. What you end up with is a method chain that someone on the business side could read aloud and follow.
The book's opening example proves it with the classic restaurant tips file: load tips.csv, add a TIP% column with the formula [TIP]*100/[TOTAL_BILL], keep only sex and tip percentage, average by sex and round. A handful of lines to answer "who tips more?"
Pipeline builder: assemble your chain
Tool 21 · Acquire
2 · Cleanse
3 · Slice & dice
4 · Show
How it reads out loud
Signatures follow the examples in the book and the README. This is a teaching sketch: check parameters against the documentation before using it in production.
Cleaning without fear
Chapter 4 is the practical heart of the book. Real data arrives with random capitalization, broken email addresses, blank cells and the occasional absurd value. Squirrel ships a Swiss Army knife of self-describing functions, and every one follows the same rule: nothing is modified in place. Each function hands back a new, cleaned table and leaves the original alone.
Missing values
RemoveIncompleteRows() drops incomplete rows; ReplaceMissingValuesByDefault fills gaps using a strategy (the book demonstrates the maximum).
Formatting
NormalizeColumn with NameCase, UpperCase or LowerCase; Transform runs your own function over every cell.
Patterns
RemoveNonMatches and RemoveMatches filter rows with regular expressions, for example to validate emails.
Privacy
MaskColumn with StarExceptLastFour or PhoneAreaCodeAndLastFour, plus AutoMask(), for GDPR- or HIPAA-style masking.
Consistency
RemoveCombination drops impossible pairings across two columns; DistinctBy removes duplicates.
Outliers
RemoveOutliers and ExtractOutliers rely on the interquartile range (IQR) method.
Cleaning lab: every step makes a new table
Tool 3Fictional data. Struck-through rows are the ones the latest step removed; gold cells are the ones it changed. Click an earlier version to confirm it is untouched. Try changing the order: filling gaps before or after dropping incomplete rows gives different results.
So what exactly is an outlier?
The IQR method sorts the values and looks at the middle half, from the first quartile (Q1) to the third (Q3). The distance between them is the interquartile range. Anything that lands too far outside that box gets flagged. It might be a typo, or it might be the most important story in your data, which is why the book also gives you ExtractOutliers: pull them aside and look before you throw them away.
Outlier detector: twelve months of power bills
Tool 4Type your own values separated by spaces. Quartiles use linear interpolation and the fences sit at 1.5 × IQR (Tukey's convention). The book says Squirrel uses the IQR method but doesn't state the multiplier, so the library's results could differ at the edges.
Your bank statement
Chapter 8 puts everything to work on real cases, and the first one hits closest to home: personal finance. Most banks let you download statements as CSV. The book uses a fictional one belonging to "Joe" and asks four questions. Where did Joe spend most of his money? How much went to food delivery? How much to coffee, and how does that compare? How do you put it on a dashboard? The recipe: SplitOn("Description") to group by merchant, sum the debit column with LINQ, turn the result back into a table with ToTableFromAnonList(), and sort. To compare months, GranularizeDateColumn adds year, month and day columns, and a Transform function maps raw descriptions to categories.
Statement analyzer (runs entirely in your browser)
Tool 5Where does the money go? (SplitOn by description, sum, sort)
| Description | Total |
|---|
Compare two merchants by month
Categories (Transform with your rules)
| Category | Total |
|---|
Each rule reads "keyword => category"; the first match wins. Nothing leaves this page: it is not sent or stored anywhere. Even so, don't paste account or card numbers. Date, description and amount are all you need.
The value isn't the chart. It's the next question the chart makes you ask. If delivery spending doubles your grocery bill in February, you know exactly what to watch in March.
Time is data too
Chapter 7 covers time series, and it's where Squirrel's friendliest side shows. Dates read like plain English: 10.MondaysFrom(DateTime.Today) gives you the next ten Mondays, (-10) gives you the previous ten, and 10.BusinessDaysFrom(...) counts ten working days. You can even add dates like numbers: DateTime.Today + 5.Mondays().
To change frequency, Resample buckets records into intervals such as month-end (MonthEnd), quarter-end (QuarterEnd) or business days. One design decision deserves applause: Squirrel refuses to up-sample (going from months to days, say), because that opens holes you could only fill by inventing values, and once that happens nobody can trace where a given number came from. To see the trend without the noise, Smooth applies five- or thirteen-point moving averages, exponential or weighted ones.
A household's power use in 120 rows
Tool 6This button shows why the library refuses to up-sample.
Synthetic, illustrative data (summer peaks plus an efficiency improvement from 2021 on); it does not come from the book. The moving average is centered, so the first and last points have no value.
Plain-English calendar
Tool 7Everyday uses: your next ten paydays on Friday, ten business days to file a form. Dates here are counted after (or before) the start date; check whether your Squirrel version includes the start date itself. Public holidays are not excluded.
Modeling the world with formulas
Squirrel doesn't only read data; it can generate it. AddColumn accepts a text formula evaluated by NCalc, a math expression engine, so you can write "[price]/[net_sqm]" for price per square meter, as in Jolicoeur's housing analysis, or "if([Qty] > 10, [Price] * 0.9, [Price])" for a bulk discount. It's made for what-if work: tweak the formula without recompiling complex logic.
The flashiest example in both the book and the README comes from physics: the speed of a 68.1 kg bungee jumper with a drag coefficient of 0.25. One column for time from 1 to 60 seconds, a helper column, and a column with the velocity formula. The chart shows the jumper is essentially at terminal velocity by about the thirteenth second.
Simulator: the bungee jumper
Tool 8Free fall with quadratic drag: v(t) = √(g·m/c)·tanh(√(g·c/m)·t), with g = 9.81 m/s². The text formula spells out the hyperbolic tangent with exponentials, exactly like the original example.
What small data tells you
To untangle the different kinds of analysis, Chapter 1 follows Raul, a restaurant owner trying to make sense of his tips. Walk through his journey:
The action. One Monday morning Raul sits down with his transaction data and looks at tips by server, by time of day and by table. Analysis is the act of examining data to answer questions.
The field and the tools. His point-of-sale system records every transaction and tip; he exports to a spreadsheet and later to specialized software. Analytics is the technology that collects and processes the data.
The reports. Dashboards with daily tip averages, tips per server, peak tipping hours and table turnover. Business intelligence turns data into reports people act on.
Hidden patterns. Looking for relationships nobody spotted by eye. That's data science.
Looking back. Raul learns that Fridays bring the best tips, holiday seasons bring more generosity, some servers consistently earn more, and window seats generate 15% more tips.
Looking forward. Using those patterns, the system projects tips for upcoming weekends, busy stretches that need extra staff and seasonal trends.
Deciding. The system recommends server schedules and which tables to assign at which times. What happened (the window) becomes what to do (who works the window on Friday).
Raul's restaurant is an illustrative story from the book, not a published study.
More cases from Chapter 8
Dogs versus cats
Using a public dataset of pet ownership by US state, the book adds calculated columns such as the dog-to-cat ratio and the gap between them. Dogs win in most states; Connecticut stands out for preferring cats.
A World Cup dashboard
For a sports journalist, it loads team statistics from an HTML table and, for every metric, places the top 10 and bottom 10 teams side by side with Dashboard and DashboardBox in Bootstrap tables.
Tables for everyone else
The same results can come out as Bootstrap, Tailwind or Markdown tables, or as Google Charts and Chart.js charts, without hand-writing HTML or JavaScript.
An LLM as co-author
Appendix B starts from a very current observation: writing code is no longer the bottleneck; verifying it is. An AI model can produce forty lines of nested LINQ in two seconds, and you spend ten minutes stepping through it for subtle bugs. Because Squirrel's methods carry business names, generated code works like an executable specification that you can audit at a glance. The book even shows how to build the system prompt by reading each method's [Description] attribute, synonyms included, through reflection.
Working with an AI assistant, step by step
Tool 9Prime the model. Give it a template with the package (TableAPI), the namespace (using Squirrel;), the rule that Table is immutable, and a closed list of allowed methods, so it doesn't invent functions that don't exist.
Describe it in plain language. For example: "Load tips.csv and find out whether women tip more than men as a percentage of the bill."
Let it generate. The model returns a Squirrel method chain. If the names match the vocabulary of the problem, you can already read it as a spec.
Inspect before believing. Before anything else, check RowCount, ColumnHeaders and Take(5).PrettyDump(). That's how you catch numbers loaded as text ("$15.50"), shifted headers or an empty file.
Refine in conversation. "Now break it down by day, sort it descending and generate an HTML chart." Every round is small and checkable.
Freeze it with a test. Turn the pipeline into a unit test that compares its output with a reference CSV (a "golden snapshot"). If something changes tomorrow, the test tells you.
What the book doesn't promise
Squirrel is honest about its territory. Know its edges (items marked "editor's note" are this article's additions):
It isn't for big data or low-latency work
It targets tiny-to-medium datasets; the README talks about 10,000 to 1 million rows. For petabytes or distributed processing, Spark and friends are still the way; for ML pipelines over millions of rows, Jolicoeur points to Microsoft.Data.Analysis.
"100k rows in under 1 second" is a README claim
The book puts ergonomics ahead of raw speed and doesn't publish detailed benchmarks. Editor's note: if timing matters in your case, measure it with your own data.
Columns are referenced by strings
Because each row is a dictionary of strings, a typo in "Salary" shows up at run time, not compile time. Editor's note: keep column names in constants and move to RecordTable<T> once the schema settles.
Always assign the result
Editor's note: if every operation returns a new table, calling data.RemoveOutliers("price") without keeping the result leaves data unchanged. Some published examples use AddColumn as if it changed the table in place; rather than rely on that detail, write var clean = data.RemoveOutliers(...) and keep working with clean.
A young project
The book mentions almost 10,000 NuGet downloads and the README more than 9,400; the repository has 26 stars, and version 1.0.5 added the Chart.js and Google Charts adapters. The author also warns of breaking changes as older chart function names are deprecated. Features such as natural-language queries (ShowMe, HowMany) are experimental.
Small data isn't harmless data
Editor's note: a bank statement or 50,000 clinic records fit on a laptop, which is exactly why they end up on USB sticks. Masking before you share is part of the analysis, not paperwork.
Take it to Monday
Pick one question from your life or your work that has been nagging you for weeks. Export the data as CSV and give it an hour. A few starting points:
At home
Bank statement: which category keeps growing month over month? Power or water bills: which months spike?
In a small business
Sales by weekday and by product; top 10 and bottom 10 customers; the hour the place fills up.
On your dev team
Error logs grouped by type and hour; features almost nobody uses; why sign-ups dropped on Tuesday.
Checklist for your first analysis
Tool 10You don't need to become a data scientist. You need a question, a CSV and the right scalpel.