Skip to content

Instantly share code, notes, and snippets.

@sudipto80
Created October 28, 2014 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sudipto80/5e40eca9efac900314c6 to your computer and use it in GitHub Desktop.
Save sudipto80/5e40eca9efac900314c6 to your computer and use it in GitHub Desktop.
Squirrel Example : Finding whether women are more generaous than men while paying tip
//Problem : Locate average percentage of Tip paid by men and women from tips.csv
//Done in 3 lines of C# code using Squirrel.NET
//Loading the data to Squirrel.NET Table is easy
Table tips = DataAcquisition.LoadCSV(@"..\..\tips.csv");
//Add a new column based on the formula
tips.AddColumn(columnName: "tip%", formula: "[tip]*100/[totbill]", decimalDigits: 3);
tips
//Pick only these columns
.Pick("sex", "tip%")
//Aggregate the Tip% values by calculating the average
.Aggregate("sex", AggregationMethod.Average)
//Round off the result till 2 decimal points
.RoundOffTo(2)
//Dump the result to console.
.PrettyDump();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment