Pandas Load CSV With Index
Load a CSV that already has an index column
- DATAFRAME
Some CSVs are plain tables with an auto-numbered index. Others ship with a real index baked in - a first column of dates, IDs, or names that identifies each row. Loading the second kind with the plain CSV node eats that column as ordinary data, and your index ends up a meaningless 0..N. PandasLoadCSVWithIndex exists to say "this file's Nth column is the index, use it."
It's part of HowToSD's ComfyUI-Data-Analysis pack, Hide Inada's pandas/matplotlib/seaborn wrapper set for ComfyUI. No GPU, no models - just the CSV loader family with one extra, important knob.
How it works
Under the hood it's pd.read_csv(file_path, index_col=index_col). The index_col input is an integer position (0-based) telling pandas which column becomes the row labels. index_col=0 - the default - makes the very first column the index, which is the common case for a file like:
player_id,team,avg_hits
a-101,Mets,0.312
a-102,Cardinals,0.289
Here player_id becomes the index and team/avg_hits are the data columns. Set index_col=1 and the second column becomes the index instead. Like the other loaders, IS_CHANGED returns NaN so the file re-reads every run, and relative paths resolve against the ComfyUI installation directory.
Why this matters: a real index unlocks the loc-based (label-based) row nodes in the pack. If your rows are identified by player IDs, you want to address them by ID - and that only works when pandas knows the IDs are the index.
The inputs that matter
- file_path - the CSV location, relative to ComfyUI's folder or absolute.
- index_col - the 0-based position of the index column. Default 0. If your index is the third column, set 2.
Output is a single DATAFRAME with that column promoted to the index.
Installing it
The standard pack install. ComfyUI Manager: search "ComfyUI-Data-Analysis", install, restart. It handles pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, and lxml automatically. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
pip install -r requirements.txt
Rename the cloned folder to data-analysis for the example workflows to resolve. License: custom non-commercial - personal and academic use is fine, commercial use needs the author's written permission.
Gotchas
The index-column position is 0-based, so index_col=0 means the first column - the same off-by-one trap as everywhere else in this pack. If you pick the wrong position, you don't get an error; you get the wrong column silently promoted and your data shifted by one. Check the loaded output before building on it. And if your CSV's index column has a name, pandas keeps that name on the index - handy for joins and display. If your file has no meaningful index at all, skip this node entirely; the plain loader's auto-index is what you want.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — | |
| index_col | INT | 00–10000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DATAFRAME | DATAFRAME | — |