Nodes/ComfyUI-Data-Analysis/Pandas Create With Index
ComfyUI Node

Pandas Create With Index

When your CSV's first column is an index, not data

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Create With Index
    • DATAFRAME
    data
    index_col0

    Pandas Create With Index is the "I know what I'm doing" version of Pandas Create. Same multiline CSV text field, same output - a DATAFRAME - but this one lets you declare that one of your columns is actually the row index, so pandas treats it as labels rather than as a column of data. It exists because a lot of real tables were exported with an ID, a date, or a name as the first column, and you want that to be the index, not another data column you have to demote later.

    Mechanically it's a read_csv with the index_col argument:

    df = pd.read_csv(StringIO(data), index_col=index_col)
    

    So everything you know about CSV parsing applies - first row becomes headers, types get inferred - plus one extra decision: which column position is the index.

    The two inputs that matter

    • data - multiline string, the CSV itself. Same as Pandas Create.
    • index_col - an integer, default 0, range 0–10000. It's the position of the index column, zero-based, so the default treats the first column as the index. Set it to 1 and the second column becomes the index instead; set it to 0 and it does the obvious thing.

    The classic beginner mistake here is using this node when you don't have an index column at all. If you set index_col = 0 on a plain CSV, your first column silently stops being a column - it becomes row labels, and any downstream node that expected it as a data column gets confused. Reach for plain Pandas Create unless you actually have a column that belongs in the index. The flip side: if you do have one and you used Pandas Create instead, you'll find yourself fumbling with set-index and rename nodes later, so choosing right up front saves a step.

    Output is a DATAFRAME with the index already set - the same wire type as everywhere else in the pack, so it chains straight into Show DataFrame, plotting, or arithmetic nodes.

    Install

    Standard 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
    

    or ComfyUI Manager → search "Data analysis" → install → restart. No GPU, no model downloads - this is a pandas wrapper, and it's the rare ComfyUI node that runs happily on the CPU with nothing heavy to fetch.

    CategoryData Analysis

    Inputs (2)

    NameTypeDefaultDescription
    dataSTRING
    index_colINT00–10000

    Outputs (1)

    NameTypeDescription
    DATAFRAMEDATAFRAME