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 87810317
FEDEX EXPRESS 58708850
UNITED AIRLINES 54763075
DELTA AIR LINES 15101496
MILITARY 13468551
GOVERNMENT 9219537
UPS AIRLINES 8234307
SOUTHWEST AIRLINES 6306153
HAWAIIAN AIR 5753650
EMERY WORLDWIDE 4425444

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
20136
Approach 17012
Take-off run 8010
Landing Roll 7400
Climb 6867
Descent 1433
En Route 1032
Taxi 157
Parked 30
Landing 17

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 11921
B-737-300 4080
A-320 3131
B-757-200 2870
CL-RJ100/200 2463
A-319 2131
B-737-700 1604
B-727-200 1481
A-300 1264
B-737-500 1111

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
ASTORIA REGIONAL 6338699
TROY MUNICIPAL ARPT 6198875.5
OGDENSBURG INTL ARPT 1757025
TONCONTIN INTL 1522755.2
BARNESVILLE-BRADFLD 976201
ANGOLA 855658
DADE-COLLIER TRAINING & TRANSITION ARPT 761378
ROSEAU MUNI ARPT/RUDY BILLBERG FLD 760644
BARROW COUNTY ARPT 723987

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
California 4959
Texas 4282
Florida 3192
New York 3024
Illinois 2444
Colorado 2419
Ohio 2327
Tennessee 1869
Michigan 1592
New Jersey 1578
Pennsylvania 1544
Kentucky 1423
Missouri 1417
Hawaii 1325
Louisiana 1305
Arizona 1227
DC 1200
Oregon 1045
Massachusetts 930
Georgia 898
Washington 862
Indiana 816
South Carolina 789
Utah 779
North Carolina 762
Nebraska 748
Maryland 726
Oklahoma 673
Minnesota 653
Virginia 595
Wisconsin 556
Connecticut 485
Alabama 478
New Hampshire 465
Iowa 432
Alaska 375
Mississippi 343
Rhode Island 313
Arkansas 293
Nevada 291
North Dakota 290
Kansas 271
New Mexico 209
Maine 196
Idaho 192
West Virginia 182
South Dakota 170
Delaware 125
Puerto Rico 111
Montana 103
Prince Edward Island 86
Vermont 75
Wyoming 71
Virgin Islands 62
British Columbia 57
Ontario 55
Alberta 26
Quebec 17
Manitoba 7
Newfoundland and Labrador 5
Nova Scotia 3
Saskatchewan 2