ComfyUI Node

Pandas Tan

Apply tangent to a DataFrame — the math node that turns garbage to NaN

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

Pandas Tan applies the tangent function to every cell of a DataFrame, and - same as its sibling Pandas Sin - it first coerces everything to numeric, turning anything it can't parse into NaN. Feed it a numeric frame, get back a frame where every value is tan(value).

Honest take: of the pack's trig nodes, this is the one you'll reach for least. Sine has a clean story (cyclic/periodic data, smooth [-1, 1] transforms). Tangent is a spikier beast - it blows up to ±infinity at the poles of its period, so a column of raw angle data can turn into a mix of huge numbers and infinities that wrecks downstream stats. But it does have real uses: slope-of-line calculations (tan of an angle is literally the slope), gradient work, and any analysis that genuinely wants a ratio of sine to cosine. If you know you need tangent, this is how you get it in the graph.

How it works

Identical structure to Pandas Sin: dataframe.apply(pd.to_numeric, errors='coerce') converts each column to numeric and marks non-numeric cells NaN, then np.tan(dataframe) is applied elementwise. So the node never errors on text - it quietly makes it missing. That's convenient, but it also means the NaN footprint propagates into any summary node downstream.

Inputs and outputs

  • dataframe (DATAFRAME) - the frame to transform. Only numeric columns are meaningful.

Output: a single DATAFRAME with tangent applied. Wire it into plotting nodes, Pandas Summary to check the result, or Pandas To Numpy for the array side of the graph.

Installing this pack

This node ships in ComfyUI-Data-Analysis by Hide Inada (HowToSD). CPU-only, no GPU, no model downloads - but the pack needs its Python stack, which stock ComfyUI lacks: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml.

ComfyUI Manager: Manager → Custom Node Manager → search "Data analysis" → install ComfyUI-Data-Analysis → restart ComfyUI and refresh the browser. Manager installs the deps.

Git clone:

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

Restart ComfyUI after installing.

Troubleshooting

  • Giant numbers or infinity everywhere. That's tangent at its poles - the input likely contains angle values near 90°/270° (π/2, 3π/2). If you didn't mean to hit singularities, reconsider whether tangent is the right transform or restrict the input range.
  • Whole column went NaN. Non-numeric data - the coercion killed it. Check the column dtype upstream.
  • Downstream stats look broken. NaN cells and infinities from tan() propagate into Pandas Summary/Pandas Std. Filter or clean the transformed frame before summarizing.
CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
dataframeDATAFRAME

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME