Nodes/ComfyUI-Data-Analysis/Pandas Series To DataFrame
ComfyUI Node

Pandas Series To DataFrame

Pandas Series To DataFrame

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Series To DataFrame
  • series
  • DATAFRAME
label
transposetrue

Round-trip node. Pandas Series To DataFrame takes a Series (which is what Pandas Select Column As Series hands you) and converts it back into a proper two-dimensional DataFrame, with a toggle that decides whether the series becomes a row or a column. It's the bridge you need when a pipeline path hands you a Series but the next node wants a table - which happens constantly once you start mixing the pack's data types.

It's part of HowToSD/ComfyUI-Data-Analysis, grouped under Transformation. The pack treats DATAFRAME, PDSERIES, and PDINDEX as distinct socket types, so converting between them is a routine operation, and this node exists to make the Series→DataFrame hop a one-node affair.

How it works

The node calls series.to_frame(name=label) and then optionally transposes. The label field names the column (or row) the series becomes; leave it blank and pandas uses the series' own name. The transpose toggle is the interesting bit:

  • transpose = True (default) - the series becomes a row, so a series with 3 values becomes a 1-row, 3-column DataFrame. That's the shape you want when the series' index values are the things you'd call columns.
  • transpose = False - the series becomes a column, producing an N-row, 1-column DataFrame, with the series' index as the row labels.

Both are legitimate depending on where the data's headed, and getting this backwards is the classic mistake.

Inputs

  • series - the PDSERIES to convert.
  • label - STRING, the name for the converted axis. Empty means use the series' name.
  • transpose - BOOLEAN, default True. True → series becomes a row; False → a column.

Output: one DATAFRAME.

Installation

Standard pack install. ComfyUI Manager: search Data analysis, install ComfyUI-Data-Analysis. Or:

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

Restart, reload. Deps: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml - no GPU, no models.

The gotchas

The transpose default will surprise you exactly once: default True gives you a wide 1-row table, and if you expected a long column, flip the toggle. Also, an unnamed Series with a blank label produces a column/row literally called 0 - give it a real label if the name matters downstream. And remember the index travels with the Series: transposed or not, the original index labels come along and become either the row labels or the column headers, so if they're meaningless (default 0..N positions), your converted table's index will be equally meaningless.

CategoryData Analysis

Inputs (3)

NameTypeDefaultDescription
seriesPDSERIES
labelSTRING
transposeBOOLEANtrue

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME