A national park’s visitor density is the number of recreatio…
A national park’s visitor density is the number of recreation visits divided by the park’s gross acreage. Some parks are tiny and absorb millions of visitors per year; others are vast and quiet. In this problem, you will rank the parks by how densely visited they are on average. Write a function named top_parks_by_density that accepts three arguments: a parks file name, a visits file name, and a number n. For each row in the visits file, compute that park’s visitor density for that year (visits divided by acres). Return a pandas Series of the n parks with the highest mean density across all years on file, sorted from highest to lowest. Open this problem in Vocareum to write and submit your solution. A few ground rules while you work: Keep this Canvas quiz and Honorlock open for the duration of the problem. Do not close or submit the quiz until you are finished in Vocareum. You do not need to write or submit anything in Canvas. We will check Vocareum for your solution. You may submit and test your solution in Vocareum as many times as you like before the quiz time limit expires. Once the quiz ends, Vocareum will lock and you will not be able to make further changes. The data file is available in your Vocareum workspace. You do not need to upload it. It is linked above only for your reference. Examples In [1]: top_parks_by_density(‘nps_parks.csv’, ‘nps_visits.csv’, 8) Out[1]: park Gateway Arch NP 8640.39 Hot Springs NP 335.26 Indiana Dunes NP 144.45 Cuyahoga Valley NP 77.55 Acadia NP 71.62 Bryce Canyon NP 63.74 Zion NP 29.98 Haleakala NP 28.11 Name: density, dtype: float64 In [2]: top_parks_by_density(‘nps_parks.csv’, ‘nps_visits.csv’, 5) Out[2]: park Gateway Arch NP 8640.39 Hot Springs NP 335.26 Indiana Dunes NP 144.45 Cuyahoga Valley NP 77.55 Acadia NP 71.62 Name: density, dtype: float64
Read Details