Slice Rows

Shipping
df_slice

numpy frame[start:stop:step] over rows — head, tail, reverse, decimate

Signature

Inputs

  • dfDataFramerequiredThe frame whose rows are sliced with numpy basic-slicing semantics.

Outputs

  • dfDataFrameThe selected (and optionally reversed / decimated) range of rows; every column reindexed the same way.

Parameters

KeyTypeDefaultNotes
startstringFirst row (numpy start). Empty = beginning. Negative counts from the end (-1 = last row).
stopstringStop row, EXCLUSIVE (numpy stop). Empty = to the end. Negative counts from the end.
stepstringStride between kept rows (numpy step). Empty = 1. Use 2/3/… to decimate, -1 to reverse. Zero is rejected.

Description

Slice Rows (df_slice) selects a range of a DataFrame's rows using the exact numpy basic-slicing semantics frame[start:stop:step]. It shares its single index-computing implementation (slice_indices) with the array slice node, so behavior is identical across the two.

All three bounds are text params so they can be empty (meaning "default"): empty start is the beginning, empty stop is the end, empty step is 1. stop is exclusive. Negative values count from the end (start = -2 is "last two rows", stop = -1 stops before the last row). A step of -1 reverses the row order; a step of k > 1 decimates (every k-th row). A zero step is rejected. Bounds accept integer or float-encoded ("3.0") forms from the Dart side.

The chosen row indices reindex every column identically, so types, units and null masks are preserved. This one node covers head (stop = n), tail (start = -n), reverse (step = -1) and decimate (step = k). Stateless.

Mathematics

Examples

Head, tail, reverse

On rows [0, 1, 2, 3, 4]:

  • stop = 3 → head: [0, 1, 2]
  • start = -2 → tail: [3, 4]
  • step = -1 → reverse: [4, 3, 2, 1, 0]

Decimate

start = 0, step = 2 keeps every other row: rows [0, 2, 4] from a 5-row frame — a 2× downsample of the table with no interpolation.

Applications

  • Taking the first / last N rows of a large imported table (head / tail) for a quick look.
  • Reversing time-ordered rows for a reverse-time view or a flip before concat.
  • Decimating a dense table to a lighter preview before plotting or export.
  • Extracting a fixed row window [start:stop] as a region of interest.

Neat

It reuses the array slice node's exact index math, so table row-slicing and array element-slicing follow identical numpy rules — one mental model for both.

All bounds are optional text fields, so head/tail/reverse/decimate are all expressed by leaving the irrelevant bounds blank rather than by mode switches.

Float-encoded bounds ("3.0") are accepted and truncated, absorbing the way the Dart/JSON layer sometimes serializes integers as doubles.

Known issues

A step of zero is a hard error (matching numpy), so an unset step must be blank or a nonzero integer.

Slicing is positional; if the table is not pre-sorted, a row window has no relation to any value range (pair with df_sort first).

See also

dataframeslicerowsnumpyhead-tail-reverse-decimatestateless