A structured array of whale species data

Question P6.1.1

Turn the following data concerning various species of cetacean into a NumPy structured array and order it by (a) mass and (b) population. Determine in each case the index at which Bryde's whale (population: 100000, mass: 25 tonnes) should be inserted to keep the array ordered.

NamePopulationMass /tonnes
Bowhead whale900060
Blue whale20000120
Fin whale10000070
Humpback whale8000030
Gray whale2600035
Atlantic white-sided dolphin2500000.235
Pacific white-sided dolphin10000000.15
Killer whale1000004.5
Narwhal250001.5
Beluga1000001.5
Sperm whale200000050
Baiji130.13
North Atlantic right whale30075
North Pacific right whale20080
Southern right whale700070

A text file containing these data is available as whale-data.txt.


Solution P6.1.1