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

Kursinnhold

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
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 1

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

course content

Kursinnhold

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
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 1
Vi beklager at noe gikk galt. Hva skjedde?
some-alt