Minnesota is the “Land of 10,000 Lakes”. But did you know there are more than 10,000 lakes in the state? The file mn_lakes.csv (right-click, open in new tab or window) contains a list of Minnesota lakes and some basic data about them. Write a function named longest_shoreline that accepts three arguments: a filename, a county name, and a number k. Return the k lakes in the county with the longest shorelines in order from longest to shortest. For full credit: Use NumPy operations to do the analysis, and use no loops or list comprehensions. Submit either a .py or a .ipynb file. Examples Nearby Lake Minnetonka obviously has the longest shoreline in our own Hennepin county, followed by Long Meadow Lake, Rice Lake, etc: In [1]: longest_shoreline(‘mn_lakes.csv’, ‘Hennepin’, 5) Out[1]: array([‘Minnetonka’, ‘Long Meadow’, ‘Rice’, ‘Anderson’, ‘Medicine’]) Minnesota’s Lake of the Woods is so massive that it exists in its own county! Unsurprisingly, Lake of the Woods has the single longest shoreline in Lake of the Woods county: In [2]: longest_shoreline(‘mn_lakes.csv’, ‘Lake of the Woods’, 1) Out[2]: array([‘Lake of the Woods (MN)’]) Otter Tail County has the most lakes in the state. Dead Lake, Star Lake, and Lida Lake lead the way in terms of longest shorelines in Otter Tail County: In [3]: longest_shoreline(‘mn_lakes.csv’, ‘Otter Tail’, 10) Out[3]: array([‘Dead’, ‘Star’, ‘Lida’, ‘Otter Tail’, ‘North Turtle’, ‘Spitzer’, ‘Big McDonald’, ‘Lizzie’, ‘West Battle’, ‘Pelican’]) The fictional town of Lake Wobegon is the county seat of the fictional Mist County, MN. Of course, there are no lakes in a fictional county, so we get an empty array: In [4]: longest_shoreline(‘mn_lakes.csv’, ‘Mist’, 10) Out[4]: array([]) Finally, for this problem at least, searches should be case sensitive: In [5]: longest_shoreline(‘mn_lakes.csv’, ‘hennepin’, 10) Out[5]: array([])
Read Details