[Python] How to create one DataFrame using Pandas?

Discussão em 'Python' iniciado por Stack, Maio 6, 2025.

  1. Stack

    Stack Membro Participativo

    Recently I am struggling to learn how to create DataFrames using Pandas being guided by Pandas' documentation. The main problems that I was having were related to the parameters of the DataFrame function. The attributes columns and index. I was using one object containing the data and was trying to create one DataFrame using that data.

    The code that I am working on and having errors is this:

    data = [["Orange", "Watermelon", "Banana", "Apple"], [10, 30, 23, 56]]
    df = pd.DataFrame(data=data[1], columns=data[0])
    print(df)


    It does not work for me, and if I remove the columns parameter it works. What can be done to solve it?

    Continue reading...

Compartilhe esta Página