Nodes/ComfyUI-Data-Analysis/Pandas Rename Advanced
ComfyUI Node

Pandas Rename Advanced

Pandas Rename Advanced

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Rename Advanced
  • dataframe
  • DATAFRAME
axis
replacement_pairs{}

The moment you're renaming more than one column, the plain Pandas Rename node becomes tedious - one label per node, five labels means five nodes. Pandas Rename Advanced is the batch version: type a single Python dictionary mapping old labels to new labels, and it renames them all in one shot. {"cat": "dog", "mouse": "rat"} and both columns are fixed. It's the node you graduate to about thirty seconds after you realize single renames don't scale.

It's from HowToSD/ComfyUI-Data-Analysis, the pandas-in-ComfyUI pack, and it's grouped with Rename under Transformation. Both call pandas' rename() under the hood; this one just parses your dictionary and hands it over as the mapping. Where the simple node is limited to strings, this one's dictionary can also handle numeric labels, which the author's own notes call out as the gap the advanced version fills.

How it works

The replacement_pairs field is a multiline string that gets parsed with Python's ast.literal_eval, so you need real Python dict syntax - keys double-quoted, commas, braces. Then the node validates it (must be a dict, values must be scalar strings or numbers - no lists or nested dicts) and calls dataframe.rename() with it on whichever axis you pick. Invalid syntax raises a clear error rather than silently doing nothing, which is a nice upgrade over the single-rename node's silent no-op behavior.

Example that works:

{"team": "club", "R": "runs", "year": "season"}

Inputs

  • dataframe - the table.
  • axis - dropdown: columns or index.
  • replacement_pairs - the dict, as a multiline STRING. Default {}.

Output: the renamed DATAFRAME.

Installation

Same pack install as everything else. Via ComfyUI Manager: search Data analysis and install ComfyUI-Data-Analysis. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis   # examples need this folder name
pip install -r requirements.txt

Restart, reload. The usual dependency stack applies - pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml - CPU only, no models, no GPU.

The trap: it's Python syntax, not JSON

People paste JSON and it breaks. JSON allows single quotes? No - JSON requires double quotes, but this node wants Python dict syntax. {"a": 1} happens to be valid both ways, so a lot of examples work by accident. Where it diverges: you can't use JSON's trailing-anything, and if you use single quotes around keys it will parse as Python but won't match what you expect if your labels literally contain quotes. Keep it simple: double-quote your labels, mind the commas, and remember the axis dropdown decides whether those labels are column names or index labels. Get that wrong and your rename silently targets the wrong namespace.

CategoryData Analysis

Inputs (3)

NameTypeDefaultDescription
dataframeDATAFRAME
axisCOMBO2 options: columns, index
replacement_pairsSTRING{}

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME