Ciaren

Rename columns

Rename columns — renameColumns

Rename columns via an old → new mapping.

Use cases

  • Normalize messy headers (amtamount, Cust IDcustomer_id).
  • Align column names across two datasets before a Join or Union/Concat.

What it does

Only the listed columns change; all others pass through untouched.

Before
amtCust IDord_dt
120.510012024-01-01
8910022024-01-02
2 rows · 3 cols
Rename columns (amt→amount, Cust ID→customer_id, ord_dt→ordered_at)
After
amountcustomer_idordered_at
120.510012024-01-01
8910022024-01-02
2 rows · 3 cols

Configuration

Config keyTypeRequiredDescription
mappingobjectYes{ "old_name": "new_name" }

Generated Python code

df_2 = df_1.rename(columns={'amt': 'amount'})

Tips & common mistakes

  • Only listed columns change; everything else passes through untouched.
  • Renaming to a name that already exists will collide — rename or drop the conflicting column first.

See also