Accessing using .loc[] [1/3]
.loc[]
is pandas property that allows to access a group of rows and columns by label(s) or a boolean array.
First, you can get rows by their indexes. Pass index/range of indexes between square brackets.
Note that right boundary is inculded while slicing within
.loc[]
123456789# 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 first row (index - 0) print(df.loc[0]) # Get the 9th - 11th rows (indexes 8, 9, 10) print(df.loc[8:10])
To get all rows, pass the colon :
between square brackets.
Grazie per i tuoi commenti!
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Mi faccia domande su questo argomento
Riassuma questo capitolo
Mostri esempi dal mondo reale
Awesome!
Completion rate improved to 3.33
Accessing using .loc[] [1/3]
Scorri per mostrare il menu
.loc[]
is pandas property that allows to access a group of rows and columns by label(s) or a boolean array.
First, you can get rows by their indexes. Pass index/range of indexes between square brackets.
Note that right boundary is inculded while slicing within
.loc[]
123456789# 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 first row (index - 0) print(df.loc[0]) # Get the 9th - 11th rows (indexes 8, 9, 10) print(df.loc[8:10])
To get all rows, pass the colon :
between square brackets.
Grazie per i tuoi commenti!