ComfyUI Node

Pandas Rename

Pandas Rename

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Rename
  • dataframe
  • DATAFRAME
axis
current_label
new_label

Every real dataset has at least one column name you want to strangle - a typo, a "value " with a trailing space, or something imported from a CSV with a name that makes no sense. Pandas Rename is the node for exactly one rename at a time: pick the axis, type the old label, type the new label, done. It's the "clean up your data before you do anything else" node, and in a pipeline it usually sits right after a load or a create.

It's part of HowToSD/ComfyUI-Data-Analysis, the extension that turns pandas operations into ComfyUI nodes. Rename is listed under Transformation, and there's a deliberate pair here: this node handles a single label with plain text fields, while Pandas Rename Advanced takes a whole dictionary of renames at once. For the one-off cleanup, this is the one you want - no syntax to get wrong.

How it works

The node calls pandas' DataFrame.rename() with a single-entry mapping. The axis dropdown picks which label namespace you're editing: columns renames a column header, index renames a row label. Then current_label is the exact label as it exists today and new_label is what it becomes. Case matters, spaces matter - if you don't hit the label exactly, pandas doesn't rename anything and silently hands you back the same table.

One honest limitation the author flags in the source: renaming works for string labels. If your columns or index are integers, this node's plain-string approach isn't the right tool - go for Rename Advanced, which can handle numeric keys.

Inputs

  • dataframe - the table.
  • axis - dropdown: columns or index.
  • current_label - the existing label, exactly as it appears.
  • new_label - what to rename it to.

Output is the updated DATAFRAME, everything else untouched.

Installation

Standard pack install. ComfyUI Manager: search Data analysis, install ComfyUI-Data-Analysis, restart, reload. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis   # example workflows rely on this name
pip install -r requirements.txt

Dependencies: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml. No GPU, no models.

The gotcha

Silent no-ops. Because pandas rename just doesn't match when the label is slightly off, the node won't error - you'll think you fixed the column and it'll still be there. Before you go looking for a bug downstream, check that the current_label is byte-for-byte identical (trailing spaces from CSV imports are the classic culprit). And remember: one rename per node instance. If you're fixing five columns, either chain five of these or jump straight to Pandas Rename Advanced, which does them all in one dict.

CategoryData Analysis

Inputs (4)

NameTypeDefaultDescription
dataframeDATAFRAME
axisCOMBO2 options: columns, index
current_labelSTRING
new_labelSTRING

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME