Limit rows
Limit rows — limitRows
Keep a slice of rows.
Use cases
- Take the top N after a Sort (e.g. top 100 customers).
- Page through data with
offset+n. - Trim a preview to a manageable size.
What it does
Returns the first n rows from the current row order. Combine with
Sort rows before limiting to get a meaningful "top N".
Before
| region | amount |
|---|---|
| South | 150 |
| West | 120 |
| North | 80 |
| East | 30 |
| Central | 10 |
5 rows · 2 cols
Limit rows (n=3)
After
| region | amount |
|---|---|
| South | 150 |
| West | 120 |
| North | 80 |
3 rows · 2 cols
Configuration
| Config key | Type | Required | Description |
|---|---|---|---|
n | int | Yes | Number of rows to keep (≥ 0; 0 keeps no rows) |
offset | int | No | Skip this many rows first (default 0) |
Generated Python code
df_2 = df_1.head(3)
Tips & common mistakes
- Limit is positional, not random — sort first for a meaningful "top N". For a random subset use Sample rows.
offsetskips from the current row order, so combine it with a deterministic Sort for stable paging.