- dataframe
- DATAFRAME
Text cleaning is the unglamorous 80% of any real data project, and Pandas Replace is the find-and-replace for your whole table. You give it a regex pattern and a replacement string, and it rewrites matching text in every cell of the DataFrame - turning "N/A" into "", stripping a stray "$" out of a price column, collapsing "New York " and "New York" into one canonical value. Leave the replacement blank and it deletes the matches outright, which is exactly how you murder inconsistent junk before it poisons a join or a plot.
It comes from HowToSD/ComfyUI-Data-Analysis, the pandas-as-ComfyUI-nodes pack. This one sits in its Data cleansing category, and it's the workhorse of the pair: a simple regex-plus-replacement interface that's easier than it looks powerful.
How it works
The mechanism is pandas' DataFrame.replace({regex: replacement}, regex=True). Two important details hide in there. First, it applies to every cell - all columns, all rows. You can't scope it to one column with this node, so if your "N/A" appears in a column where "N/A" is a legitimate value, this node will hit it everywhere. Second, the first field is a regular expression, not a plain substring - and it's used as a regex across the whole cell by default (the code calls it without a regex column restriction, so treat it as full-cell pattern matching). A bare N/A works as a literal, but characters like . and $ are special and will surprise you.
Inputs
dataframe- the table to clean.regex- the pattern to find (a regular expression).replacement_string- what to replace it with. Leave empty to delete.
Output: a cleaned DATAFRAME, shape unchanged.
Installation
The 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 # examples rely on this folder name
pip install -r requirements.txt
Deps: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml. No GPU, no models.
Gotchas
Regex is the whole game here. Want a literal dollar sign? Escape it: \$. Want to remove everything after a comma? ,.*. And since it scans all columns, be deliberate - cleaning "0" to "" will strip zeros out of numeric-looking cells too, which is a data-loss footgun if those cells are actually numbers stored as text. If you need surgical, per-value replacement instead of regex, the pack's Pandas Replace Advanced takes an exact-value dictionary and is the safer choice for literal cleanup. When in doubt: replace nothing, run a Show DataFrame node first, and check what you're about to mutate.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — | |
| regex | STRING | — | |
| replacement_string | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATAFRAME | DATAFRAME | — |