Data.Gov - 2006-2008 Crime in the United States (Data.gov)

Category:
TypeProviders.AzureMarketPlace
Description: Consume Azure Marketplace crime data from Data.gov. For more information, please goto https://datamarket.azure.com/dataset/c663117f-db6d-49e1-bc83-b05390bb3c70
Code:
type C = Microsoft.FSharp.Data.TypeProviders.ODataService < ServiceUri = @"https://api.datamarket.azure.com/data.gov/Crimes" >

let DataGov() =
let crime = new C.ServiceTypes.datagovCrimesContainer()
//To sign up for a Windows Azure Marketplace account, please go to https://datamarket.azure.com/account/info
crime.Credentials<- NetworkCredential (Utils.ADM_USER_ID, Utils.ADM_ACCOUNT_ID)

// compare different property crime rates for cities around microsoft
query {
for m in crime.CityCrime do
where (m.City = "Redmond" || m.City = "Kirkland" || m.City = "Bellevue" || m.City = "Seattle" )
where (m.State = "Washington")
where (m.Year = 2008)
sortBy (m.City)
} |> Seq.map ( fun c -> (c.City, (float c.Burglary + float c.PropertyCrime) / float c.Population * 100.0))
|> Seq.sortBy(fun d -> snd d )
|> Seq.toList
|> printfn "%A"

// sample output
// [("Redmond", 3.717874241); ("Bellevue", 4.063400812); ("Kirkland", 4.584304584);
// ("Seattle", 6.574905907)]


Execution Result:
[("Redmond", 3.717874241); ("Bellevue", 4.063400812); ("Kirkland", 4.584304584);
("Seattle", 6.574905907)]

Last edited Mar 1, 2012 at 7:05 PM by ttliu2000, version 4

Comments

No comments yet.