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 airports have the most expensive average accident? by Karen Blakemore
// First group by airport
var airports = _.groupBy(data, 'Airport.Name')
// Then collect costs of birdhits
var costByAirport = _.mapValues(airports, function(d) {
return _.pluck(d, 'Cost.Total')
})
// Next, calculate averge cost for each airport
var avgCostByAirport = _.mapValues(costByAirport, function(d) {
var nums = _.map(d, function(n) {
return _.parseInt(n.split(',').join(''))})
return _.sum(nums)/nums.length
})
// Finally, convert object to array type and sort by avg cost
var sortedAvgCostByAirport =
_.sortByOrder(
_.pairs(avgCostByAirport),
function(d) {return d[1]},
'desc')
// Just return top 10
return _.take(sortedAvgCostByAirport, 10)
Top 10 Airports With Most Expensive Average Accident
| NICE (FRANCE) | 10135286 |
| TROY MUNICIPAL ARPT | 6198875.5 |
| ASTORIA REGIONAL | 2112899.6666666665 |
| OGDENSBURG INTL ARPT | 1757025 |
| LA ISABELA INTL ARPT | 1500000 |
| TONCONTIN INTL | 1099149 |
| BARNESVILLE-BRADFLD | 976201 |
| ANGOLA | 855658 |
| LOGAN COUNTY ARPT | 852169 |
| ROSEAU MUNI ARPT/RUDY BILLBERG FLD | 760644 |
Which airport has the most bird hits? by Brian McKean
names = _.filter(data,function(n){
return n['Airport']['Name'] != "UNKNOWN"
})
airports = _.groupBy(names, 'Airport.Name')
var incidents = _.mapValues(airports,function(n){
return n.length
})
big = _.max(incidents)
most = _.pick(incidents,function(n){
return n == big
})
return most
The worse airport is DENVER INTL AIRPORT with 3397 incidents
Which airline incurs the most repair cost due to damage? by Mingqi Lew
var group = _.groupBy(data, "Aircraft.Airline");
var repair_sum = _.mapValues(group, function(n){
var repair = _.pluck(n, "Cost.Repair")
return _.sum(repair)
})
var max = _.max(repair_sum);
var highest_repair = _.pick(repair_sum, function(d){
return d == max;
});
return highest_repair
| BUSINESS | 54721 |
Which plane model strikes the most birds? by Matt Schroeder
return "[answer]"
(Question 5) by (Name)
return "[answer]"