Practice / selecting and filtering

Flag the Long Rides

easy

CityCycle wants to tag its longer trips without losing the short ones.

You have the rides DataFrame:

Your task: keep all columns and add a boolean column is_long that is true when minutes is greater than 20 and false otherwise.

Assign your answer DataFrame to result. Row order doesn't matter.

ridesinput DataFrame

Schema
columntype
ride_idlong
minuteslong
Sample rows
ride_idminutes
112
225
340
420
Expected output shape
ride_idminutesis_long· 4 rows
Hint

Add a column, don't drop rows: withColumn("is_long", F.col("minutes") > 20). A comparison expression is already a boolean column — no when needed.

Lesson refresher

This problem builds on Selecting & Filtering (~6 min). Pop it open in a new tab if you want a quick recap.

Loading editor…
Hit Run to execute your code and see the output here.