Nodes/ComfyUI-Data-Analysis/Pandas Loc Row Series
ComfyUI Node

Pandas Loc Row Series

One whole row, by label, as a Series

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Loc Row Series
  • dataframe
  • PDSERIES
row_index
row_index_type

Here's the scenario: you've loaded a table of data, and you want to yank out one entire record - all its columns at once - and do something with it. Pandas Loc Row Series is that node. Give it a DataFrame and a row label, and it returns that row as a PDSERIES, the pack's socket type for a pandas Series. It's the "give me row 4, whatever's in it" node, and it's the simplest member of the pack's loc family.

It comes from the ComfyUI-Data-Analysis pack by Hide Inada (HowToSD) - the extension that brings pandas, Seaborn, and Matplotlib into the ComfyUI canvas so you can run real data analysis next to image generation. The loc nodes handle label-based selection, which is worth knowing because it's the source of most confusion here.

How it works

The node runs dataframe.loc[row_index]. The key word is loc: it selects by label, not by position. The author's own user guide calls this out explicitly - in pandas, the "index" is a label attached to each row, not a row number. So a plain CSV loaded fresh has a 0, 1, 2… RangeIndex, and to grab the fourth row you'd pass 3 and set row_index_type to int. If your index is names, dates, or strings, keep the default string.

The row_index_type dropdown decides whether the node casts your typed text to an integer before the lookup. Get that wrong and you get a KeyError on a row that's clearly there - the classic loc trap.

The output is the whole row as a PDSERIES. From there you can wire it into Pandas Mul Series / Pandas Add Series for element-wise math, convert it back with Pandas Series To DataFrame, or stringify it for display. If you only need one cell, use Pandas Loc Cell String instead.

The inputs that matter

  • dataframe - the DATAFRAME to pull from.
  • row_index - the row's label, as text.
  • row_index_type - string or int. Match this to your actual index dtype.

How to install it

Part of the single pack install:

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

ComfyUI Manager works too - search "Data analysis" and install. Restart ComfyUI and reload the page afterward. The pack drags in pandas, matplotlib, seaborn, scipy, and scikit-learn; no GPU, no model files.

Common issues

  • KeyError for a row you can see - 95% of the time it's the label type enum. Fresh-loaded CSVs have integer RangeIndexes; set row_index_type to int.
  • Wrong row comes back - you're treating labels as positions. If you want the nth row regardless of labels, that's Pandas Iloc Row Series (positional), not this node.
  • You expected a cell - a Series is a whole record. Use Pandas Loc Cell String for a single value.

Short version: loc = by label, iloc = by position. Pick the right one and this node is boring in the best way.

CategoryData Analysis

Inputs (3)

NameTypeDefaultDescription
dataframeDATAFRAME
row_indexSTRING
row_index_typeCOMBO2 options: string, int

Outputs (1)

NameTypeDescription
PDSERIESPDSERIES