Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Accessing Rows and Columns | Accessing DataFrame Values
Introduction to pandas [track]

bookAccessing Rows and Columns

If you need to get particular rows and columns, you can easily combine both methods learned previously, in any order. That is, you can get certain row, and then choose the columns you need, or vice versa. Look at the example below, and compare both outputs.

12345678
# Importing library import pandas as pd # Reading csv file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/67798cef-5e7c-4fbc-af7d-ae96b4443c0a/audi.csv') # Get the 'mileage' column value of the first row print(df[0:1]['mileage']) print(df['mileage'][0])
copy

Remember that you need to use slicing even for getting a single row.

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 5

Spør AI

expand

Spør AI

ChatGPT

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

Awesome!

Completion rate improved to 3.33

bookAccessing Rows and Columns

Sveip for å vise menyen

If you need to get particular rows and columns, you can easily combine both methods learned previously, in any order. That is, you can get certain row, and then choose the columns you need, or vice versa. Look at the example below, and compare both outputs.

12345678
# Importing library import pandas as pd # Reading csv file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/67798cef-5e7c-4fbc-af7d-ae96b4443c0a/audi.csv') # Get the 'mileage' column value of the first row print(df[0:1]['mileage']) print(df['mileage'][0])
copy

Remember that you need to use slicing even for getting a single row.

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 5
some-alt