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.
Which airport has the highest number struck? by twagar95
var groups = _.groupBy(data, function(n){
return n['Airport: Name']
})
var valuedGroups = _.values(groups)
var result = _.chain(valuedGroups)
.map(function(arr){
return [arr[0]["Airport: Name"], arr.length]
})
.reduce(function(n, p){
if ((n[1] > p[1]) && (n[0] != "UNKNOWN")) { return n; } else {return p; }
}).value()
return result
What states cost the airlines the most money? by SatchelSpencer
return _.chain(data).groupBy('Origin State').mapValues(function(state){
return _.reduce(state, function(sum, incident){
return sum+parseInt(incident['Cost: Total $'].toString().replace(',', ''));
}, 0);
}).pairs().sortByOrder('1', 1).object().value();
| California |
2127423 |
| Louisiana |
1093625 |
| Michigan |
809569 |
| Florida |
762698 |
| N/A |
732517 |
| Utah |
668183 |
| Kansas |
618303 |
| Minnesota |
599694 |
| Missouri |
534880 |
| New Jersey |
485576 |
| Texas |
439716 |
| Ohio |
425544 |
| South Carolina |
392892 |
| West Virginia |
318186 |
| Alaska |
297876 |
| Pennsylvania |
262622 |
| DC |
260538 |
| North Carolina |
213986 |
| Massachusetts |
211480 |
| Oregon |
208581 |
| Arizona |
188042 |
| Indiana |
130761 |
| Virginia |
115062 |
| Nebraska |
111386 |
| Georgia |
87532 |
| Colorado |
86431 |
| Oklahoma |
78280 |
| Kentucky |
49681 |
| New York |
46144 |
| South Dakota |
43432 |
| Alabama |
43101 |
| Maryland |
42764 |
| Connecticut |
34455 |
| Mississippi |
30870 |
| Wisconsin |
18041 |
| Arkansas |
15734 |
| Washington |
14166 |
| Tennessee |
14032 |
| Illinois |
13899 |
| Delaware |
6682 |
| Nevada |
5346 |
| Rhode Island |
0 |
| Puerto Rico |
0 |
| Maine |
0 |
| Hawaii |
0 |
| New Hampshire |
0 |
| Vermont |
0 |
| North Dakota |
0 |
| British Columbia |
0 |
| Iowa |
0 |
| Idaho |
0 |
| New Mexico |
0 |
| Ontario |
0 |
| Montana |
0 |
| Wyoming |
0 |
| Virgin Islands |
0 |
| Quebec |
0 |
| Prince Edward Island |
0 |
| Newfoundland and Labrador |
0 |
| Saskatchewan |
0 |
What is the frequency of bird strikes at various height ranges ? by sumi6109
//filter all the data which have feet above the ground greater than zero
var data_poistive=_.filter(data,function(r){return parseInt(r['Feet above ground'])> 0})
//group all the data based on feet above the ground greater than zero
var grps =_.groupBy(data_poistive,function(d){return d['Feet above ground']})
var result=_.mapValues(grps,function(t){return t.length})
var sorted = _.sortBy(_.pairs(result), function(d) {
return parseInt(d[0].replace(',', ''));
});
var desc = _(sorted).value()
return desc
//return result
| Height |
Number of birds hit |
| 2 |
6 |
| 3 |
7 |
| 4 |
1 |
| 5 |
23 |
| 7 |
2 |
| 9 |
3 |
| 10 |
82 |
| 12 |
1 |
| 15 |
10 |
| 20 |
62 |
| 25 |
10 |
| 30 |
20 |
| 34 |
1 |
| 35 |
2 |
| 38 |
1 |
| 40 |
12 |
| 50 |
134 |
| 60 |
2 |
| 70 |
2 |
| 75 |
12 |
| 80 |
2 |
| 85 |
1 |
| 90 |
3 |
| 100 |
150 |
| 105 |
1 |
| 110 |
1 |
| 120 |
1 |
| 125 |
2 |
| 140 |
1 |
| 150 |
24 |
| 180 |
1 |
| 200 |
108 |
| 250 |
7 |
| 300 |
81 |
| 350 |
6 |
| 360 |
1 |
| 400 |
52 |
| 450 |
1 |
| 500 |
100 |
| 550 |
1 |
| 600 |
21 |
| 650 |
1 |
| 700 |
19 |
| 750 |
3 |
| 760 |
1 |
| 775 |
1 |
| 800 |
50 |
| 850 |
1 |
| 900 |
13 |
| 930 |
1 |
| 950 |
1 |
| 1,000 |
88 |
| 1,100 |
8 |
| 1,150 |
1 |
| 1,200 |
26 |
| 1,300 |
7 |
| 1,400 |
9 |
| 1,500 |
65 |
| 1,600 |
8 |
| 1,700 |
8 |
| 1,800 |
15 |
| 1,900 |
11 |
| 2,000 |
70 |
| 2,081 |
1 |
| 2,100 |
5 |
| 2,200 |
4 |
| 2,300 |
7 |
| 2,400 |
3 |
| 2,500 |
31 |
| 2,600 |
4 |
| 2,700 |
2 |
| 2,800 |
3 |
| 2,900 |
1 |
| 2,970 |
1 |
| 3,000 |
56 |
| 3,100 |
1 |
| 3,200 |
5 |
| 3,300 |
4 |
| 3,400 |
2 |
| 3,500 |
13 |
| 3,700 |
1 |
| 4,000 |
27 |
| 4,100 |
1 |
| 4,200 |
1 |
| 4,300 |
1 |
| 4,700 |
1 |
| 5,000 |
37 |
| 5,100 |
2 |
| 5,500 |
4 |
| 5,600 |
1 |
| 5,800 |
1 |
| 6,000 |
11 |
| 6,200 |
1 |
| 6,300 |
1 |
| 6,500 |
3 |
| 7,000 |
20 |
| 7,200 |
1 |
| 7,500 |
1 |
| 7,700 |
1 |
| 8,000 |
12 |
| 8,300 |
2 |
| 8,500 |
1 |
| 8,900 |
1 |
| 9,000 |
3 |
| 9,500 |
1 |
| 9,650 |
1 |
| 10,000 |
4 |
| 10,500 |
2 |
| 10,800 |
1 |
| 11,000 |
6 |
| 12,000 |
6 |
| 12,300 |
1 |
| 12,500 |
1 |
| 12,600 |
1 |
| 13,000 |
1 |
| 15,000 |
1 |
| 16,000 |
1 |
| 17,000 |
1 |
| 21,000 |
1 |
What are the top 5 bird species that are involved? by nicolele
var clean = _.reject(data, function(n){
return _.includes(n['Wildlife: Species'], 'Unknown')
})
var groups = _.groupBy(clean, function(d){
return d['Wildlife: Species']
})
var birds = _.pairs(_.mapValues(groups, function(value){
return value.length
}))
var top = _.sortBy(birds, function(n) {
return n[1]
}).reverse()
return _.slice(top, [start=0], [end=5])
| Gulls |
251 |
| Mourning dove |
163 |
| European starling |
121 |
| Sparrows |
98 |
| Rock pigeon |
95 |
(What Airline loses the most money to bird strikes every year?) by (John)
var groups = _.groupBy(data, function(n){
return n['Aircraft: Airline/Operator']
})
var pairs = _.pairs(_.mapValues(groups, function(item){
var costs = _.map(item, function(value){
return parseInt(value['Cost: Total $'].toString().replace(',', '')) })
return _.sum(costs)
}))
var top = _.sortBy(pairs, function(n){
return n[1]
}).reverse()
top = _.slice(top, [start =0], [end=10])
return top
| BUSINESS |
3528807 |
| MILITARY |
1748247 |
| NORTHWEST AIRLINES |
840942 |
| AMERICAN EAGLE AIRLINES |
801820 |
| FEDEX EXPRESS |
711967 |
| SOUTHWEST AIRLINES |
669519 |
| KLM ROYAL DUTCH AIRLINES |
534547 |
| AMERICAN AIRLINES |
511087 |
| EXECUTIVE JET AVIATION |
492513 |
| CONTINENTAL AIRLINES |
490932 |