Skip to content

Instantly share code, notes, and snippets.

@ptrelford
Last active August 29, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptrelford/39040f169df466a1be77 to your computer and use it in GitHub Desktop.
Save ptrelford/39040f169df466a1be77 to your computer and use it in GitHub Desktop.
FsiBot Data Science Prototype
#r "System.Windows.Forms.DataVisualization.dll"
#r @"..\packages\FSharp.Charting.0.90.7\lib\net40\FSharp.Charting.dll"
#r @"..\packages\FSharp.Data.2.0.14\lib\net40\FSharp.Data.dll"
open FSharp.Data
open FSharp.Charting
let wb = WorldBankData.GetDataContext()
type Indicator = Runtime.WorldBank.Indicator
type Indicators = WorldBankData.ServiceTypes.Indicators
[<AutoOpen>]
module Countries =
let uk = wb.Countries.``United Kingdom``.Indicators
let fr = wb.Countries.France.Indicators
let de = wb.Countries.Germany.Indicators
// ....
let (/.) (a:Indicator) (b:Indicator) =
(Chart.Combine
[Chart.Line(a,a.Code+" "+a.Name);
Chart.Line(b,b.Code+" "+b.Name)] )
.WithLegend()
.ShowChart()
let (|.) (a:Indicator) (b:Indicator) =
(Chart.Combine
[Chart.Column(a,a.Code+" "+a.Name);
Chart.Column(b,b.Code+" "+b.Name)] )
.WithLegend()
.ShowChart()
let (=>) (xs:Indicators seq) (f:Indicators -> Indicator) =
(Chart.Combine
(xs |> Seq.map(fun x ->
let i = f x
Chart.Line(i,i.Code+" "+i.Name))))
.WithLegend()
.ShowChart()
// What you send to FsiBot:
uk.``GDP (constant 2005 US$)`` /. fr.``GDP (constant 2005 US$)``
uk.``Energy related methane emissions (% of total)`` /. fr.``Energy related methane emissions (% of total)``
uk.``GDP (constant 2005 US$)`` |. fr.``GDP (constant 2005 US$)``
[uk;fr;de] => (fun i -> i.``GDP (constant 2005 US$)``)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment