[Python] df.head() is returning ValueError: Per-column arrays must each be 1-dimensional

Discussão em 'Python' iniciado por Stack, Junho 28, 2025.

  1. Stack

    Stack Membro Participativo

    Here is my code:

    set_theme_count = sets_df["theme_id"].value_counts()[:-5]


    Result: [​IMG]

    Now, I want to rename the columns so I can use pd.merge. So this is what I did:

    set_theme_count = pd.DataFrame({'id' :set_theme_count.index,
    'set_count': set_theme_count.values})


    This code runs successfully, but when I try to do set_theme_count.head(), I am getting this error:

    ValueError: Per-column arrays must each be 1-dimensional


    I am very confused since the DataFrame gets created successfully, but the .head() throws an error. Also, if there is another way to rename the columns, please let me know.

    I am using google collab.

    Continue reading...

Compartilhe esta Página