Pandas Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

loc

A

loc is primarily label based; when two arguments are used, you use column headers and row indexes to select the data you want. loc can also take an integer as a row or column number.

df.loc[0,’Artist’]: ‘Michael Jackson’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

iloc

A

iloc is integer-based. You use column numbers and row numbers to get rows or columns at particular positions in the data frame.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

iloc slicing

A

z=df.iloc[0:2,0:3]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Import pandas

A
Pandas have a list of functions including:
read_csv()
Series()
DataFrame
values

import pandas as pd
csv_path = “a.csv”
df = pd.read_csv(csv_path)

df.head() examines the frist 5 rows of data frame.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

create new dataframe consisting of one column

A

x=df[[‘Length’]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

create multiple columns

A

y=df[[‘Artist’, ‘Length’, ‘Genre’]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly