#!/usr/bin/env python # coding: utf-8 # In[2]: import pandas as pd # In[3]: #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 # In[10]: #Size of dataframe df.shape # In[11]: #Transposing a dataframe df.T # In[7]: #Dropping a column #axis=1 is for column df.drop(['age'], axis=1) # In[8]: #If you dont'put inplace the orginical df remains same df # In[9]: #Dropping a row #axis=0 for row df.drop([1], axis=0) # In[14]: #Scalar addition df['big_age'] = df['age'] + 10 df # In[17]: #we can add two columns #Think it as matrix addition df['bigger_age'] = df['age'] + df['big_age'] df # In[19]: #Scalar multiplication df['biggest_age'] = df['age']*10 df