Select columns
Select columns — selectColumns
Keep only the listed columns (and reorder them).
Use cases
- Produce a tidy output with just the columns that matter, in a chosen order.
- Reduce a wide frame to the few columns a downstream step needs.
What it does
Drops every column not listed and reorders the survivors to match your list.
Before
| id | name | region | amount | notes | created_at |
|---|---|---|---|---|---|
| 1 | Alice | North | 120.5 | vip | 2024-01 |
| 2 | Bob | South | 89 | null | 2024-01 |
2 rows · 6 cols
Select columns (columns=[amount, region, id])
After
| amount | region | id |
|---|---|---|
| 120.5 | North | 1 |
| 89 | South | 2 |
2 rows · 3 cols
Configuration
| Config key | Type | Required | Description |
|---|---|---|---|
columns | string[] | Yes | Columns to keep, in order |
Generated Python code
df_2 = df_1[['region', 'amount']]
Tips & common mistakes
- Order matters — the output columns follow the order you list them in.
- To drop just a couple of columns from a wide frame, use Drop columns instead.