import pandas as pd
#Read the csv file
titanic_df = pd.read_csv('titanic.csv')
#It's a big file so let's extract a small data out of it
df = titanic_df.loc[[0,1,2,3,4,5],['name','sex','age','fare']]
df
#Let's just print the name
df.name
#we can print the name using loc also
df.loc[:,'name']
#iloc can be used with positional integers
#First two rows and all columns
df.iloc[0:2,:]
#all rows and last column
df.iloc[:,-1]
#show the index
df.index
#using criteria to filter
df[df.sex == 'female']
df[df.index == 2]
#we can use conditions
df[(df.sex == 'female') & (df.age >= 20)]