Select Columns
Shippingdf_selectKeep or drop a subset of DataFrame columns by name or index; reorder in keep mode
Signature
Inputs
dfDataFramerequired— The frame to reproject onto a subset of its columns.
Outputs
dfDataFrame— A frame with only the kept columns; each column keeps its type, unit and null mask.
Parameters
| Key | Type | Default | Notes |
|---|---|---|---|
columns | string | Comma-separated column names or 0-based indices (e.g. `time, 2, voltage`). In Keep mode the output order follows this list. Case-insensitive names. | |
mode | enum | keep | one of: keep, drop |
Description
Select Columns (df_select) is a pure column reprojection over a DataFrame. The columns param is a comma-separated list of column names or 0-based indices, and mode decides whether that list is the set to keep or to drop.
In keep mode the output contains exactly the listed columns, in the order you listed them — so df_select doubles as a column reorderer (c, a puts c first). An empty selection in keep mode is an error, since a zero-column frame is almost never intended. In drop mode the output keeps every column not named, preserving their original order.
Selectors are resolved case-insensitively: an all-digit token is a positional index, anything else is matched against column names. An unresolvable token is a hard error naming the offender. Every kept column is cloned intact — its logical type (f64 / i64 / str / bool / datetime), its unit, and its null mask all survive unchanged. The node is stateless.
Mathematics
Examples
Keep and reorder
On a frame [a, b, c], columns = "c, a" with mode = keep yields [c, a] — a subset and a reorder in one step.
Drop the rest
On the same [a, b, c], columns = "b" with mode = drop yields [a, c] in original order.
Applications
- Trimming an imported table down to the few columns of interest before plotting or export.
- Reordering columns so a chosen time/X column leads for df_to_signals.
- Dropping bookkeeping columns (row ids, flags) that should not become signal channels.
- Building a tidy, minimal frame ahead of df_concat so column counts line up for a row stack.
Neat
Keep mode is order-preserving on the selector list, so a single node both subsets and permutes columns — no separate reorder node needed.
Column identity accepts names or indices interchangeably (case-insensitive), so the same node works whether or not your table has headers.
Selection is a clone-by-index of existing columns, so types, units and null masks are guaranteed intact — nothing is re-parsed or coerced.
Known issues
An empty column list in keep mode is rejected (would produce a zero-column frame); use drop mode if you really want to remove almost everything.
Duplicate tokens in keep mode duplicate the column in the output — intentional for reshaping, but surprising if unintended.