BuildlyBuildly
DashboardExercisesProfileHelp
Data Science/Module 2: Data Analytics/Selection & Indexing1/3
Exercise·7 min·10 XP

Slice Rows by Position

Context. Grab a positional slice of rows, regardless of the DataFrame's index.

Your task. Write rows_by_position(df, start, stop) that returns rows from position start (inclusive) to stop (exclusive), using positional indexing.

Example. A 5-row df with start=1, stop=3 → rows at positions 1 and 2.

Notes. Same semantics as Python list slicing. start == stop → empty DataFrame. stop > len(df) → returns through end.

Previous
Pick a Single Column
Next
Filter Rows by a Threshold