Nodes/ComfyUI-Data-Analysis/Py Kv Int Create
ComfyUI Node

Py Kv Int Create

A Key Plus an Integer Becomes a Dict — That's the Whole Trick

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Py Kv Int Create
    • PYDICT
    key
    value0

    The dict-building family in this pack has one node per value type, and Py Kv Int Create is the integer member: string key in, integer value in, {key: value} out. If your data is counts, IDs, or row numbers, this is the one you want instead of the float variant.

    It exists because several IO nodes - Pandas Create From Dict being the main one - take a PYDICT and build a DataFrame from it. This node lets you assemble that dict from widgets instead of typing a literal.

    How it works

    It returns {key: value} where the value is typed as an INT widget (default 0, clamped to the 32-bit signed range). So key="count", value=12 gives you {"count": 12}. The output is a PYDICT, the pack's shared dictionary socket type.

    The practical difference from Py Kv Float Create is honesty about types. An integer value stays an integer through the dict, which matters when that dict flows into a DataFrame and you later want df["count"].astype(int)-style behavior without surprises. Pandas would survive a float either way, but keeping the type clean costs nothing.

    Inputs and outputs

    • key - the dictionary key, as a string.
    • value - the integer to store under that key.

    Output: one PYDICT with the single pair.

    Install

    Part of HowToSD/ComfyUI-Data-Analysis. Via Manager: search "Data analysis" in the Custom Node Manager, install, restart, reload the browser tab. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
    mv ComfyUI-Data-Analysis data-analysis   # README: example workflows need this folder name
    pip install -r requirements.txt
    

    Lightweight - no models, no GPU, just Python.

    Common issues

    Same shape as the float version: one entry per node, no merging. For a multi-key dict, use multiple create nodes feeding a multi-dict consumer, or hand-type with Py String To Dict. If you feed an int-keyed dict to something expecting float values downstream, that's on you - the node faithfully produces what you asked. And remember the INT widget clamps to 32-bit; huge values won't fit, which is fine for almost everything you'd build by hand in a graph.

    CategoryData Analysis

    Inputs (2)

    NameTypeDefaultDescription
    keySTRING
    valueINT0-2147483648–2147483648

    Outputs (1)

    NameTypeDescription
    PYDICTPYDICT