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
Table iris = DataAcquisition.LoadCSV(@"iris.csv"); | |
StringBuilder builder = new StringBuilder(); | |
builder.AppendLine("<html>"); | |
builder.AppendLine("<h2>Range</h2>"); | |
builder.AppendLine(iris.Aggregate("Name", AggregationMethod.Range).ToHTMLTable()); | |
builder.AppendLine("<h2>Average</h2>"); | |
builder.AppendLine(iris.Aggregate("Name", AggregationMethod.Average).ToHTMLTable()); |
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
Table births = DataAcquisition.LoadCSV(@"..\..\births.csv"); | |
var splits = births.SplitOn("sex"); | |
var boys = splits["boy"].Aggregate("state").Drop("year"); | |
var girls = splits["girl"].Aggregate("state").Drop("year"); | |
Table combined = new Table(); | |
combined.AddColumn("State", boys["state"]); | |
combined.AddColumn("Boys", boys["births"]); |
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
//Stock symbols of companies for which you want to run this | |
string[] symbols = { "AAPL", "GOOG", "MSFT" }; | |
Dictionary<string, Table> stocks = new Dictionary<string, Table>(); | |
string template = @"http://real-chart.finance.yahoo.com/table.csv?s=[Symbol]&d=8&e=4&f=2014&g=d&a=0&b=2&c=1962&ignore=.csv"; | |
foreach (var symb in symbols) | |
{ | |
WebClient wc = new WebClient(); | |
wc.DownloadFile(template.Replace("[Symbol]", symb), "temp" + symb + ".csv"); | |
stocks.Add(symb, DataAcquisition.LoadCSV("temp" + symb + ".csv").Top(30)); | |
} |
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
#r @"C:\Users\mukhsudi\Documents\GitHub\SquirrelLatest\ConsoleApplication2\bin\Debug\TableAPI.dll" | |
//type NameAndSex = {Name : string ; Sex : string} | |
type SurvivalStat = {PClass : string; Died : float; Survived :float} | |
let titanic = Squirrel.DataAcquisition.LoadCSV(@"C:\titanic.csv") | |
let classes = titanic.SplitOn("Pclass") | |
let result = new Squirrel.Table() | |
let pClasses = [|"1";"2";"3"|] | |
let persons = pClasses |> Array.map ( fun pClass -> | |
{ |
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
Table books = DataAcquisition.LoadCSV(@"C:\personal\books.csv"); | |
//genre,author,height-genre*author | |
books.AddColumn("GenreAsNum", books.ValuesOf("Genre")); | |
books.Transform("GenreAsNum", x => x == "fiction" ? "1" : x == "nonfiction" ? | |
"2" : x == "philosophy" ? | |
"3" : x == "science" ? | |
"4" : x == "tech" ? | |
"5" : | |
"-1"); | |
books = books.Transform("Author", x => |
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
Moon is Down, The Steinbeck fiction 196 | |
Winter of Our Discontent, The Steinbeck fiction 196 | |
Grapes of Wrath, The Steinbeck fiction 196 | |
Great Indian Novel, The Tharoor fiction 198 | |
20000 Leagues Under the Sea Verne fiction 190 | |
Slaughterhouse Five Vonnegut fiction 198 | |
---------- | |
Title Author Genre Height | |
Final Crisis fiction 257 | |
Crisis on Infinite Earths fiction 258 |
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
Table books = DataAcquisition.LoadCSV(@"C:\personal\books.csv"); | |
//genre,author,height-genre*author | |
books.AddColumn("GenreAsNum", books.ValuesOf("Genre")); | |
books.Transform("GenreAsNum", x => x == "fiction" ? "1" : x == "nonfiction" ? | |
"2" : x == "philosophy" ? | |
"3" : x == "science" ? | |
"4" : x == "tech" ? | |
"5" : | |
"-1"); | |
books = books.Transform("Author", x => |
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
void Main() | |
{ | |
string word = "abcd"; | |
List<List<string>> letters = new List<List<string>>(); | |
letters = word.ToCharArray().Select(w => new List<string>(){w.ToString().ToLower(),w.ToString().ToUpper()} ).ToList(); | |
CartesianProduct(letters) | |
.Select (x => x.Aggregate ((a,b) => a + b)) |
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
void Main() | |
{ | |
string tsql = @"CREATE EVENT SESSION [CheckMyQuery] ON SERVER | |
ADD EVENT sqlserver.lock_acquired(SET collect_database_name=(1),collect_resource_description=(1) | |
ACTION(package0.collect_cpu_cycle_time,sqlos.task_time,sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_id,sqlserver.database_name,sqlserver.nt_username,sqlserver.plan_handle,sqlserver.query_hash,sqlserver.server_instance_name,sqlserver.session_id,sqlserver.session_nt_username,sqlserver.sql_text,sqlserver.username) | |
WHERE ([sqlserver].[equal_i_sql_unicode_string]([database_name],N'MyDB'))), | |
ADD EVENT sqlserver.lock_released( | |
ACTION(sqlos.task_time,sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_name,sqlserver.nt_username,sqlserver.query_hash,sqlserver.server_instance_name,sqlserver.session_nt_username,sqlserver.sql_text,sqlserver.username) | |
WHERE ([sqlserver].[database_name]='MyDB')), | |
ADD EVENT sqlserver.lock_timeout( |
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
var range = Enumerable.Range(1,40); | |
var mod3 = range.Where(e => e % 3 == 0); | |
var mod5 = range.Where(e => e % 5 == 0); | |
var mod15 = mod3.Intersect(mod5); | |
//Find numbers that are divisible by 3 but not by 5 or 15 | |
mod3 = mod3.Except(mod15); | |
//Find numbers that are divisible by 5 but not by 3 or 15 | |
mod5 = mod5.Except(mod15); | |
//Find integers that are not divisible by either 3 or 5 |