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 occur 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 105315
Take-off run 47656
Landing Roll 45676
Climb 41636
Descent 8128
En Route 7892
Landing 1260
Taxi 860
Parked 240
null 89
When: Phase of flight 3
18 birdstrikes1.csv 3
Approach 1

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 17460
Gulls 11180
American kestrel 10604
Killdeer 10404
European starling 8800

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": 28784 }

{
 "Airplane": 28784
}

How many flights were canceled by bird strikes(pail4944)? 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> [ [ "7", 3 ], [ "Effect: Impact to flight", 3 ], [ "null", 89 ], [ "Engine Shut Down", 912 ], [ "Precautionary Landing", 14556 ], [ "", 172716 ], [ "None", 198796 ] ]

What states cost the airlines the most money? (Andrew Berumen)

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

    return _.sortBy(_.pairs(statesCost), function(c) {
        return c[1]
    }).reverse().slice(1,11)

Florida 110696
Texas 86868
California 86156
New York 35176
Tennessee 25232
Michigan 25120
Ohio 23444
Illinois 23124
Nebraska 22588
Indiana 19896