book

Report

As a team, answer a subset of the questions submitted during the hackathon. But instead of using Tableau, you will need to write Javascript/Lodash code to derive your answers. Similar to before, each team member is responsible for one question. But everyone should work together to come up with a good solution. Your answer should consist of Lodash code and a brief writeup. Utilize _.map, _.filter, _.group ...etc. Do not se any for loop.

This time, the data is not already prepared for you in a nice JSON format. You will need to do it on your own, replacing the placeholder birdstrike.json with real data.

(What phase of flight do strikes occour most often) by (Andrey Shprengel)

grps = _.groupBy(data, "When: Phase of flight")
grps = _.pick(grps, function(value, key){return key != ""})
grps =  _.mapValues(grps, function(value, key){
	return _.size(value)})
grps = _.pairs(grps)
grps = _.sortBy(grps, function(n){
	return n[1]}).reverse()
return grps

Approach 26329
Take-off run 11914
Landing Roll 11419
Climb 10409
Descent 2032
En Route 1973
Landing 315
Taxi 215
Parked 60

What are the top 5 bird species that are involved? (Caleb Hsu)

var species = _.groupBy(data, 'Wildlife: Species')
var birds = _.mapValues(species, function(s) {
    return s.length
})
var clean = _.pick(birds, function(value, key) {
    return key[0] != "U"
})

return _.sortBy(_.pairs(clean), function(c) {
    return c[1]
}).reverse().slice(0, 5)

Mourning dove 4365
Gulls 2795
American kestrel 2651
Killdeer 2601
European starling 2200

(How many flights were canceled by birdstrikes?) by (Andrew Linenfelser)

var group = _.groupBy(data, 'Effect: Impact to flight')
var types = _.pairs(_.mapValues(group, function(m){
	return m.length
}))

var sort = _.sortBy(types, function(f){
	return f[1]
})
var p = _.pullAt(sort, 4, 5)
console.log(sort)

var total = _.sum(sort, function(t){
	return t[1]
	})
return total
console> [ [ "Engine Shut Down", 228 ], [ "Aborted Take-off", 1300 ], [ "Other", 1359 ], [ "Precautionary Landing", 3639 ] ]
There were: 6526 cancellations due to bird strikes

What type of aircraft has the most instances of damaged caused by bird strikes? (Zhili Yang)

var filter=_.filter(data, function(air){
    return air['Effect: Indicated Damage'] == "Caused damage"
})
var groups=_.groupBy(filter, function(air){
    return air['Aircraft: Type']
})
var maxGroups=_.mapValues(groups, function(g){
    return _.size(g)
})
var maxType=_.pick(maxGroups, function(g){
    return g == _.max(maxGroups)
})
console.log(maxType);
return maxType
console> { "Airplane": 7196 }

{
 "Airplane": 7196
}

What states cost the airlines the most money? (Cost and location) by Andrew Berumen

var groups =  _.groupBy(data, 'Origin State')
var statesCost = _.mapValues(groups, function(d){
	var cost = _.pluck(d, 'Cost: Total $')
	return  _.sum(cost)
})

return statesCost

{
 "New Jersey": 3654,
 "N/A": 35589,
 "Colorado": 4621,
 "Illinois": 5781,
 "New York": 8794,
 "Florida": 27674,
 "Ohio": 5861,
 "California": 21539,
 "Utah": 2806,
 "Missouri": 3661,
 "Tennessee": 6308,
 "Texas": 21717,
 "Rhode Island": 1497,
 "Georgia": 4032,
 "Maryland": 3802,
 "Louisiana": 3966,
 "North Carolina": 4225,
 "Puerto Rico": 103,
 "Connecticut": 1781,
 "DC": 960,
 "Michigan": 6280,
 "Wisconsin": 3465,
 "Oregon": 4543,
 "Indiana": 4974,
 "Nevada": 1008,
 "Maine": 218,
 "Alabama": 3826,
 "Mississippi": 938,
 "Hawaii": 1731,
 "South Carolina": 645,
 "Massachusetts": 2102,
 "Alaska": 2321,
 "Arizona": 1722,
 "New Hampshire": 1310,
 "Pennsylvania": 3097,
 "Washington": 2757,
 "Minnesota": 2978,
 "Virginia": 3576,
 "Oklahoma": 4438,
 "Kentucky": 4667,
 "Kansas": 1199,
 "Vermont": 600,
 "Arkansas": 2596,
 "Nebraska": 5647,
 "South Dakota": 2473,
 "North Dakota": 1362,
 "British Columbia": 83,
 "Iowa": 387,
 "Idaho": 1042,
 "West Virginia": 269,
 "New Mexico": 1347,
 "Ontario": 874,
 "Montana": 771,
 "Wyoming": 674,
 "Virgin Islands": 100,
 "Quebec": 0,
 "Prince Edward Island": 700,
 "Delaware": 1309,
 "Newfoundland and Labrador": 0,
 "Saskatchewan": 0,
 "Alberta": 0,
 "Manitoba": 0,
 "Nova Scotia": 0
}