Notable National Parks
Problem
DataFrame: `nationalpark` (`nationalpark.csv`)
```text
+-----------------+--------+
| Column | Type |
+-----------------+--------+
| park_name | object |
| region | object |
| area_sq_km | int |
| annual_visitors | int |
+-----------------+--------+
park_name uniquely identifies each park. One row per park.
```
A park counts as **notable** if EITHER of these holds:
- its `area_sq_km` is at least 4000, OR
- its `annual_visitors` is at least 1000000.
Return the `park_name`, `annual_visitors`, and `area_sq_km` of every notable park, in any order.
Input data
Example rows — the live problem includes the full dataset.
| park_name | region | area_sq_km | annual_visitors |
|---|---|---|---|
| Cedar Ridge | North | 5200 | 320000 |
| Maple Hollow | East | 760 | 95000 |
| Granite Falls | West | 1100 | 1450000 |
| Willow Marsh | South | 240 | 18000 |
| Pine Crest | North | 6400 | 2100000 |
Expected output
Your answer should return 3 rows with the columns park_name, annual_visitors, area_sq_km.
Starter code (Pandas (Python))
import pandas as pd
def notable_parks(nationalpark: pd.DataFrame) -> pd.DataFrame:
# Your code here
return nationalparkSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock