1
resposta

Bem sinistro!

Eis o print, quando executo a célula para ler a head do dataframe, aparece a janela mostrada no print e se rolar ela para baixo, aparecem nomes de alguns animais, conforme demonstro abaixo: ![](Print de um retorno de execução no colab mostrando um resultado difeente do esperado ) pandas.core.generic.NDFrame.head def head(n: int=5) -> Self /usr/local/lib/python3.11/dist-packages/pandas/core/generic.py Return the first n rows.

This function returns the first n rows for the object based on position. It is useful for quickly testing if your object has the right type of data in it.

For negative values of n, this function returns all rows except the last |n| rows, equivalent to df[:n].

If n is larger than the number of rows, this function returns all rows.

Parameters

n : int, default 5 Number of rows to select.

Returns

same type as caller The first n rows of the caller object.

See Also

DataFrame.tail: Returns the last n rows.

Examples

df = pd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion', ... 'monkey', 'parrot', 'shark', 'whale', 'zebra']}) df animal 0 alligator 1 bee 2 falcon 3 lion 4 monkey 5 parrot 6 shark 7 whale 8 zebra

Viewing the first 5 lines

df.head() animal 0 alligator 1 bee 2 falcon 3 lion 4 monkey

Viewing the first n lines (three in this case)

df.head(3) animal 0 alligator 1 bee 2 falcon

For negative values of n

df.head(-3) animal 0 alligator 1 bee 2 falcon 3 lion 4 monkey 5 parrot

1 resposta

Olá, Roger! Como vai?

A maneira correta para utilizar o método head() é usando junto com os parênteses dessa forma:

dados.head()

E você pode ainda definir a quantidade dos primeiros elementos que deseja visualizar. Assim:

dados.head(5)

Espero ter ajudado e fico à disposição se precisar.

Abraço e bons estudos!

Caso este post tenha lhe ajudado, por favor, marcar como solucionado