AnalystPath

Recommendable Trails

PandasEasyJunior level~10 min

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_idtrail_namesummaryscore
1Cedar Ridgescenic ridge8.4
2Fog Hollowmuddy loop7.1
3Iron Passclosed5.9
4Lupine Meadowgentle stroll8.0
5Granite Spiresteep climb9.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 trail

Solve 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

Related Pandas questions