ComfyUI Node

Pandas Log

Natural logs on a DataFrame, with the mess cleaned up

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Log
  • dataframe
  • DATAFRAME

If you've ever stared at a distribution of prices, click counts, or pixel intensities and thought "this needs a log transform before it's useful," this is your node. Pandas Log applies the natural logarithm to every numeric value in a DataFrame. It's a classic preprocessing step - log transforms tame right-skewed data and turn multiplicative relationships into additive ones, which is exactly the kind of thing you want before feeding numbers into a model or a chart.

It's part of ComfyUI-Data-Analysis, the pack from Hide Inada (HowToSD) that wraps pandas into ComfyUI so your data pipelines can live in the same canvas as your image workflows. Pandas Log sits in the pack's math section alongside Pandas Exp, Pandas Sin, Pandas Cos, and friends - a set of element-wise transforms you chain between your data and your plots.

How it works

Two steps, both visible in the source. First it runs dataframe.apply(pd.to_numeric, errors='coerce'), which tries to coerce every cell to a number and turns anything that isn't - text, blanks, garbage - into NaN. Then it applies np.log over the whole frame.

That coercion step is the nice touch. Raw data almost always has a few strings or empty cells in it, and without that pass your log would just crash on a non-numeric value. With it, the non-numerics quietly become NaN and the math proceeds. Do keep in mind the standard log gotchas: log of 0 is -inf (and NumPy will warn), log of a negative number is NaN. If your data can dip to zero or below, expect those to come out as infinity/missing.

The inputs that matter

Genuinely one input: dataframe. Feed it the DATAFRAME you want transformed.

Output is a DATAFRAME of the same shape, with numeric columns logged and non-numerics as NaN. It wires straight into the next Pandas node, or a Seaborn/Matplotlib plot from the same pack.

How to install it

It's part of the pack, so:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis
pip install -r requirements.txt

or ComfyUI Manager → search "Data analysis" → install. Restart and reload. The pack installs pandas, matplotlib, seaborn, scipy, and scikit-learn alongside it - chunky but shared. No GPU, no model downloads.

Common issues

  • -inf where you expected a number - your data has zeros. Log(0) is undefined and pandas/NumPy express that as negative infinity.
  • NaN spreading everywhere - negatives, or non-numeric cells being coerced. The NaNs aren't a bug; that's the coercion working. Drop or clean them before plotting if the chart complains.
  • "Floating point error" warnings - usually harmless, but they're a hint your data has values log can't handle.

This is one of those quiet utility nodes you won't reach for daily - but when you need a log transform, it's exactly one node instead of a detour through a script.

CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
dataframeDATAFRAME

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME