[Python] Accessing Multiple Columns in Pandas (PYTHON)

Discussão em 'Python' iniciado por Stack, Novembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    I was given a file to practice pandas on, and was asked this question:

    Q: Access the last 10 rows and the first two columns of the index dataframe.

    So, I tried this code:

    df = index[(index.tail(10)) & (index.iloc[:, :2])]
    df


    but it gave me an error. How do I access the last 10 rows and first two columns of a dataframe?

    I expected to have the last 10 rows of the first two columns in a variable.

    Continue reading...

Compartilhe esta Página