Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende The `head()` Method | Fetching Data from DataFrames
Pandas: First Steps
course content

Contenido del Curso

Pandas: First Steps

Pandas: First Steps

1. Getting Started
2. Basics of Dataframes
3. Fetching Data from DataFrames

book
The `head()` Method

The head() method is used to fetch the first few rows of a DataFrame.

By default, it fetches the first 5 rows, but you can specify how many rows you want using the n named paramter.

Syntax:

python

Example:

123456789101112131415
import pandas as pd # Create a simple DataFrame data = { 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eva', 'Frank'], 'Age': [24, 30, 22, 29, 25, 28] } df = pd.DataFrame(data) print('Show the first 5 rows:') print(df.head()) print('Show the first 3 rows:') print(df.head(3))
copy
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 1

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

course content

Contenido del Curso

Pandas: First Steps

Pandas: First Steps

1. Getting Started
2. Basics of Dataframes
3. Fetching Data from DataFrames

book
The `head()` Method

The head() method is used to fetch the first few rows of a DataFrame.

By default, it fetches the first 5 rows, but you can specify how many rows you want using the n named paramter.

Syntax:

python

Example:

123456789101112131415
import pandas as pd # Create a simple DataFrame data = { 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eva', 'Frank'], 'Age': [24, 30, 22, 29, 25, 28] } df = pd.DataFrame(data) print('Show the first 5 rows:') print(df.head()) print('Show the first 3 rows:') print(df.head(3))
copy
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 1
Lamentamos que algo salió mal. ¿Qué pasó?
some-alt