Pandas Method read_csv() Flashcards

1
Q

How to create Data Set Object ?

A

df = pd.read_csv(‘dataSets/titanic.csv’)

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

How to create Data Set Object with no header ?

A

df = pd.read_csv(‘dataSets/titanic.csv’,header=None)

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

How to create Data Set Object by specifying header row ?

A

df = pd.read_csv(‘dataSets/titanic.csv’,header=0)

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

How to create Data Set object with custom column labels ?

A

df = pd.read_csv(‘dataSets/titanic.csv’,prefix=’Col-‘)

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

How to create Data Frame Object with selected columns, also manually assign column labels to them ?

A

colNames=[‘Col-1’,’Col-2’,’Col-3’,’Col-4’]

df = pd.read_csv(‘dataSets/titanic.csv’,usecols=[1,3,4,5],names=colNames)

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

How to create a Data Frame object , by changing datatype of column ?

A

df2 = pd.read_csv(‘dataSets/titanic.csv’,dtype={‘Survived’:’boolean’})

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

How to assign column names manually while loading csv File ?

A

colNames=[‘Col-1’,’Col-2’,’Col-3’,’Col-4’]

df = pd.read_csv(‘dataSets/titanic.csv’,usecols=[1,3,4,5],names=colNames)

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

How to present unique values of colums ?

A

We have to use unique() method ?

df[‘Sex’].unique()

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