[Python] Constructing DataFrame from values in variables yields "ValueError: If using all...

Discussão em 'Python' iniciado por Stack, Abril 16, 2025.

  1. Stack

    Stack Membro Participativo

    I have two variables as follows.

    a = 2
    b = 3


    I want to construct a DataFrame from this:

    df2 = pd.DataFrame({'A':a, 'B':b})


    This generates an error:

    ValueError: If using all scalar values, you must pass an index


    I tried this also:

    df2 = (pd.DataFrame({'a':a, 'b':b})).reset_index()


    This gives the same error message. How do I do what I want?

    Continue reading...

Compartilhe esta Página