Created
October 28, 2014 02:01
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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