Recommendable Trails
Problem
You are given a DataFrame `trail` with columns `trail_id`, `trail_name`, `summary`, and `score`. Each row describes a hiking trail.
Return every trail that has an **odd** `trail_id` and whose `summary` is not exactly the word `closed`. Keep all four columns, and order the result by `score` from highest to lowest.
Input data
Example rows — the live problem includes the full dataset.
trail
| trail_id | trail_name | summary | score |
|---|---|---|---|
| 1 | Cedar Ridge | scenic ridge | 8.4 |
| 2 | Fog Hollow | muddy loop | 7.1 |
| 3 | Iron Pass | closed | 5.9 |
| 4 | Lupine Meadow | gentle stroll | 8.0 |
| 5 | Granite Spire | steep climb | 9.3 |
Expected output
Your answer should return 2 rows with the columns trail_id, trail_name, summary, score.
Starter code (Pandas (Python))
import pandas as pd
def recommendable_trails(trail) -> pd.DataFrame:
# Your code here
return trailSolve 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