Nodes/ComfyUI-Data-Analysis/Pandas Create Series From Dict
ComfyUI Node

Pandas Create Series From Dict

One-dimensional data, dict-shaped

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Create Series From Dict
  • data
  • PDSERIES

Not every piece of data in this pack is a table. Sometimes you have a one-dimensional sequence - a single column's worth of values - and a pandas Series is the right object for it. Pandas Create Series From Dict builds that Series from a Python dict, and it's the less-obvious but genuinely useful sibling of the two DataFrame-from-dict nodes.

The key mental model: this is not "a dict of columns." It's a dict where the keys become the index labels and the values become the cell values. {"Mays": 3600, "Aaron": 3771} produces a Series with two rows labeled Mays and Aaron. That's the whole trick - the dict is the Series, index and all.

That's why there's a hard constraint baked into the code: every value must be a scalar. If any value is a list, dict, set, or tuple, the node raises ValueError("Value must be a scalar."). You cannot build a Series from a dict of lists - that's a DataFrame's job, and the DataFrame-from-dict nodes handle it. Empty dicts return an empty Series rather than erroring, which is handy for "no data" branches.

Inputs and outputs: required data (PYDICT), output PDSERIES - the pack's Series wire type. Feed it from Py String To Dict and you've got a named, labeled Series without touching a table.

Where this pays off

Series flow through this pack in two useful directions. First, they're the natural denominator for division - Pandas Div Series divides a whole DataFrame by a single Series, and that Series has to come from somewhere. Second, selection nodes like Pandas Boolean Index and Pandas Loc Row Series return or consume Series. Building one from a dict is the fastest way to have a labeled Series on hand when a downstream node wants one.

It's also the answer to "I just want one column of numbers with named rows." A full DataFrame for that is ceremony; a Series is the honest object.

Install

Same pack, same story:

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. No GPU, no models. And as always with this pack's text-widget inputs, connect PYDICT wires at the top-left corner of the field or the socket will refuse to appear.

CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
dataPYDICT

Outputs (1)

NameTypeDescription
PDSERIESPDSERIES