Pandas Method read_csv() Flashcards
How to create Data Set Object ?
df = pd.read_csv(‘dataSets/titanic.csv’)
How to create Data Set Object with no header ?
df = pd.read_csv(‘dataSets/titanic.csv’,header=None)
How to create Data Set Object by specifying header row ?
df = pd.read_csv(‘dataSets/titanic.csv’,header=0)
How to create Data Set object with custom column labels ?
df = pd.read_csv(‘dataSets/titanic.csv’,prefix=’Col-‘)
How to create Data Frame Object with selected columns, also manually assign column labels to them ?
colNames=[‘Col-1’,’Col-2’,’Col-3’,’Col-4’]
df = pd.read_csv(‘dataSets/titanic.csv’,usecols=[1,3,4,5],names=colNames)
How to create a Data Frame object , by changing datatype of column ?
df2 = pd.read_csv(‘dataSets/titanic.csv’,dtype={‘Survived’:’boolean’})
How to assign column names manually while loading csv File ?
colNames=[‘Col-1’,’Col-2’,’Col-3’,’Col-4’]
df = pd.read_csv(‘dataSets/titanic.csv’,usecols=[1,3,4,5],names=colNames)
How to present unique values of colums ?
We have to use unique() method ?
df[‘Sex’].unique()