Accessing Rows and Columns
Veeg om het menu te tonen
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])
Remember that you need to use slicing even for getting a single row.
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 3. Hoofdstuk 5
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Sectie 3. Hoofdstuk 5