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.

This report is prepared by

which airlines have the worst luck with birdstrikes in terms of damage caused?

var groups = _.groupBy(data, function(n){
	return n['Aircraft: Airline/Operator']
})
var i = 0
var costs = _.mapValues(groups, function(d){
	var total = _.reduce(d, function(total, e){
		var cost = e['Cost: Total $']
		if (_.isString(cost)){
			var temp1 = cost.replace(/,/g,'')
			var temp2 = _.parseInt(temp1)
			cost = temp2
		}
		return total+cost
	},0)
	return total
})
var sorted = _.sortBy(_.pairs(costs), function(d){
	return d[1]
})

return _.slice(_(sorted).reverse().value(), 0,10)

Airline Total Cost
BUSINESS 103565746
FEDEX EXPRESS 80529838
UNITED AIRLINES 74830899
US AIRWAYS 40259138
DELTA AIR LINES 20337701
MILITARY 16899033
SOUTHWEST AIRLINES 11792223
GOVERNMENT 9983201
UPS AIRLINES 8597069
PRIVATELY OWNED 7304241

what is the most common flight phase where a birdstrike occurred?

var groups = _.groupBy(data, function(n) {
    return n['When: Phase of flight']
})

var counts = _.mapValues(groups, function(d){
    return d.length
})
var sorted = _.sortBy(_.pairs(counts), function(d) {
    return d[1]
})

return _.slice(_(sorted).reverse().value(), 0,10)

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

Which plane strikes the most birds?

var groups = _.groupBy(data, function(n) {
    return n['Aircraft: Make/Model']
})

var counts = _.mapValues(groups, function(d){
    return d.length
})

var sorted = _.sortBy(_.pairs(counts), function(d) {
    return d[1]
})

return _.slice(_(sorted).reverse().value(), 0,10)
The table lists the top 10 aircraft makes that had the most incidents.

Aircraft Make/Model Strike Count
UNKNOWN 24637
B-737-300 5524
A-320 4654
CL-RJ100/200 4262
B-737-700 4046
B-757-200 3945
A-319 3138
EMB-145 2067
A-300 2055
B-727-200 1771

what airports have the most expensive average accident?

var groups = _.groupBy(data, function(n) {
    return n['Airport: Name']
})
var i = 0
var costs = _.mapValues(groups, function(d){
	var avg = _.reduce(d, function(total,e){
		var cost = e['Cost: Total $']
		if (_.isString(cost)){
			var temp1 = cost.replace(/,/g,'')
			cost = _.parseInt(temp1)	
		}
		return total+cost
	},0)/_.size(d)
	return avg
})
var sorted = _.sortBy(_.pairs(costs), function(d) {
    return d[1]
})

return _.slice(_(sorted).reverse().value(), 0,10)

Airline Total Cost
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

what state had the highest number of bird strikes?

var grps = _.groupBy(data, 'Origin State')

var map = _.mapValues(grps, function(d){
    return d.length
})

var newvar = _.map(map, function(v,k){
	return {"state": k, "count":v}
})

_.remove(newvar, function(n){
 	return n.state == 'N/A'	
})

return _.sortBy(newvar, "count").reverse()

StateStrike Count
Texas 7824
California 7803
Florida 5322
New York 4986
Colorado 4214
Illinois 3987
Ohio 3537
Tennessee 3057
New Jersey 2936
Pennsylvania 2781
Missouri 2435
Michigan 2294
Kentucky 2178
Louisiana 2147
Hawaii 2009
Arizona 1776
DC 1645
Georgia 1514
Massachusetts 1494
Oregon 1493
Washington 1446
North Carolina 1399
Indiana 1330
Nebraska 1265
Maryland 1238
Utah 1237
South Carolina 1127
Minnesota 1105
Oklahoma 1013
Wisconsin 985
Virginia 951
Connecticut 808
Alabama 745
Iowa 717
Kansas 636
New Hampshire 603
Alaska 570
Mississippi 544
Arkansas 463
North Dakota 450
Rhode Island 431
Nevada 429
New Mexico 372
South Dakota 331
Maine 318
West Virginia 286
Delaware 284
Idaho 283
Montana 181
Puerto Rico 169
Wyoming 148
Prince Edward Island 144
Vermont 138
Ontario 92
British Columbia 84
Virgin Islands 80
Alberta 32
Quebec 27
Manitoba 10
Newfoundland and Labrador 8
Nova Scotia 5
Saskatchewan 4