<jupyter_start><jupyter_text>exploring and processing data -part1<jupyter_code>#imports
import pandas as pd
import numpy as np
import os

raw_data_path = os.path.join(os.path.pardir,'data', 'raw')
train_file_path = os.path.join(raw_data_path, 'train.csv')
test_file_path = os.path.join(raw_data_path, 'test.csv')
#read data with all default parameters
train_df = pd.read_csv(train_file_path, index_col="PassengerId" )
test_df = pd.read_csv(test_file_path, index_col='PassengerId')
#get the type
type(train_df)<jupyter_output><empty_output><jupyter_text>Basic Structure<jupyter_code>#use .info() to get the basic information about data frame
train_df.info()
test_df.info()
test_df['Survived'] = -888 #adding survived with default value
df = pd.concat((train_df,test_df),axis=0, sort=False)
df.info()
#use head() to get top 5 rows
df.head()
#use get(10) to get the top 10 rows
df.head(10)
#use tail() to get last 5 rows
df.tail()
#use tails(10) to get last 10 rows
df.tail(10)
#column selecting using dot
df.Name
#column selecting using string
df["Name"]
df[["Name","Age"]]
#use loc for label based indexing
#all columns
df.loc[5:10,]
#use column based indexing
df.loc[5:10, 'Pclass':'Age']
#selecting discrete columns
df.loc[5:10, ['Survived', 'Fare', 'Embarked']]
#indexing: use iloc for position based indexing
df.iloc[5:10]
df.iloc[5:10, 3:8]
#filter rows based on the condition
male_passengers = df.loc[((df.Sex == 'male') & (df.Pclass == 1)), :]
print("number of male passenegers first class: {0}".format(len(male_passengers)))<jupyter_output>number of male passenegers first class: 179<jupyter_text>Summary Statics<jupyter_code>df.describe()
#numericality feture
#centrality measure
print("Mean Fare:{0}".format(df.Fare.mean()))
print("Median Fare:{0}".format(df.Fare.median()))
#dispersion measure
print("Min Fare:{0}".format(df.Fare.min()))
print("Max Fare:{0}".format(df.Fare.max()))
print("Fare range:{0}".format(df.Fare.max()-df.Fare.min()))
print("25 percentile:{0}".format(df.Fare.quantile(0.25)))
print("50 percentile:{0}".format(df.Fare.quantile(0.5)))
print("75 percentile:{0}".format(df.Fare.quantile(0.75)))
print("Variance Fare:{0}".format(df.Fare.var()))
print("standard deviation Fare:{0}".format(df.Fare.std()))
%matplotlib inline
#box whisker-plot
df.Fare.plot(kind='box')
#use describe(include='all') to get statics for all columns inlcuding non numeric one
df.describe(include='all')
#categorical column: count
df.Sex.value_counts()
#categorical column : Proportions
df.Sex.value_counts(normalize=True)
#apply on other columns
df[df.Survived != -888].Survived.value_counts()
# passenger class proportion
df.Pclass.value_counts()
#visulize counts
df.Pclass.value_counts().plot(kind="bar")
#title: set title, rot: horizenatl labeling, color: for set colour
df.Pclass.value_counts().plot(kind="bar", title="my bar", rot=0, color="c");<jupyter_output><empty_output><jupyter_text>Distributions<jupyter_code>#use hist to create histogram
df.Age.plot(kind='hist', title="Age histogram",color="c" );
#use bins to add or remove bins
df.Age.plot(kind="hist", title="Age histogram", color="c", bins=20);
#use kde for density plot
df.Age.plot(kind="kde", title="Age KDE", color="c");

#histogram for Fare
df.Fare.plot(kind="hist", title="Fare histogram", color="c");
#use scatter plot for bivariate distribution
df.plot.scatter(x="Age", y="Fare", title="Scatter for Age vs Fare" );
#use alpha for transparency in scatter plot.O is the lower 1 is the higher
df.plot.scatter(x="Age", y="Fare", color="c", title="Scatter for Age vs Fare", alpha=0.1);
df.plot.scatter(x="Pclass", y="Fare", color="c", title="Scatter for Age vs Fare", alpha=0.15);<jupyter_output><empty_output><jupyter_text>Grouping And Aggregation<jupyter_code>#group by sex
df.groupby('Sex').Age.median()
#group by Pclass 
df.groupby("Pclass").Fare.median()
#group by Pclass Age median
df.groupby("Pclass")["Fare", "Age"].median()
#group by Pclass Fare mean, Age median
df.groupby("Pclass").agg({"Fare": "mean", "Age": "median"})
#complicated Aggregation
aggregations = {
    "Fare":{
        "mean_Fare": "mean",
        "median_Fare": "median",
        "max_Fare": max,
        "min_Fare": np.min
    },
    "Age":{
        "median_Age":"median",
        "min_Age": min,
        "max_Age": max,
        "range_Age": lambda x: max(x)-min(x)
    }
}
df.groupby(["Pclass"]).agg(aggregations)
df.groupby(["Pclass", "Embarked"]).Fare.median()<jupyter_output><empty_output><jupyter_text>cross tabs<jupyter_code>#cross tabs on sex and pclass
pd.crosstab(df.Sex, df.Pclass)
#bar for cross tab
pd.crosstab(df.Sex, df.Pclass).plot(kind="bar", rot=0);
#pivot table
df.pivot_table(index="Sex", columns="Pclass", values="Age", aggfunc="mean")
df.groupby(["Sex", "Pclass"]).Age.mean()
df.groupby(["Sex", "Pclass"]).Age.mean().unstack()<jupyter_output><empty_output><jupyter_text>Data munging: Working with missing values<jupyter_code>#extract the rows with embarked as null
df[df.Embarked.isnull()]
#use .info() to treat missing values any
df.info();<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 1309 entries, 1 to 1309
Data columns (total 11 columns):
Survived    1309 non-null int64
Pclass      1309 non-null int64
Name        1309 non-null object
Sex         1309 non-null object
Age         1046 non-null float64
SibSp       1309 non-null int64
Parch       1309 non-null int64
Ticket      1309 non-null object
Fare        1308 non-null float64
Cabin       295 non-null object
Embarked    1307 non-null object
dtypes: float64(2), int64(4), object(5)
memory usage: 162.7+ KB<jupyter_text>Feature Embarked<jupyter_code>#extr
#extract the rows with embarked null
df.Embarked.value_counts()
#which embarked point has highest number of survivals
pd.crosstab(df[df.Survived != -888].Survived, df[df.Survived != -888].Embarked)
#impute the missing values with 'S'
#df.loc[df.Embarked.isnull,'Embarked'] = 'S'
#df.Emabarked.fillna('S', inplace=True)
#option2: explore the fare of each class for each embarkment point  
df.groupby(['Pclass','Embarked']).Fare.median()
#replace the missing values with 'C'
df.Embarked.fillna('C',inplace=True)
#check if any null values remaining
df[df.Embarked.isnull()]
df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 1309 entries, 1 to 1309
Data columns (total 11 columns):
Survived    1309 non-null int64
Pclass      1309 non-null int64
Name        1309 non-null object
Sex         1309 non-null object
Age         1046 non-null float64
SibSp       1309 non-null int64
Parch       1309 non-null int64
Ticket      1309 non-null object
Fare        1308 non-null float64
Cabin       295 non-null object
Embarked    1309 non-null object
dtypes: float64(2), int64(4), object(5)
memory usage: 162.7+ KB<jupyter_text>Feature:Fare<jupyter_code>df[df.Fare.isnull()]
median_fare = df.loc[(df.Pclass== 3) & (df.Embarked == 'S'),'Fare'].median()
print median_fare
#fill missing value with median fare
df.Fare.fillna(median_fare, inplace=True)

df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 1309 entries, 1 to 1309
Data columns (total 11 columns):
Survived    1309 non-null int64
Pclass      1309 non-null int64
Name        1309 non-null object
Sex         1309 non-null object
Age         1046 non-null float64
SibSp       1309 non-null int64
Parch       1309 non-null int64
Ticket      1309 non-null object
Fare        1309 non-null float64
Cabin       295 non-null object
Embarked    1309 non-null object
dtypes: float64(2), int64(4), object(5)
memory usage: 162.7+ KB<jupyter_text>Feature:Age<jupyter_code>#set maxium rows to be displayed
pd.options.display.max_rows = 15
#return null rows
df[df.Age.isnull()]<jupyter_output><empty_output><jupyter_text>option1: replace all missing age with mean value<jupyter_code>df.Age.plot(kind='hist', bins=20, color='c');
#get mean
df.Age.mean()<jupyter_output><empty_output><jupyter_text>issue: due to high values 70 80's pushing the overall mean<jupyter_code>#replace the missing values
#df.Age.fillna(df.Age.mean(), inplace=True)<jupyter_output><empty_output><jupyter_text>option2: replace with median age of gender<jupyter_code>#median values
df.groupby('Sex').Age.median()
#visulize using box plot
df[df.Age.notnull()].boxplot('Age','Sex')
#replace age sex median
#age_sex_median = df.groupby('Sex').Age.median()
#df.Age.filna(age_sex_median,inplace=True)<jupyter_output><empty_output><jupyter_text>option3: replace with median age of pclass<jupyter_code>df[df.Age.notnull()].boxplot('Age', 'Pclass');
#replace 
#pclass_age_median = df.groupby('Pclass').Age.transform('median')
#df.Age.fillna(pclass_age_median, inplace=true)<jupyter_output><empty_output><jupyter_text>option4: replace mediaan age of title<jupyter_code>df.Name
#funtion to extract the title from name
def getTitle(name):
    name_with_title = name.split(",")[1]
    title = name_with_title.split(".")[0]
    title = title.strip().lower()
    return title
#use map function to apply the function to each name value row
df.Name.map(lambda(x): getTitle(x))#alternativey you can use: df.Name.map(GetTitle)
df.Name.map(lambda(x): getTitle(x)).unique()
def GetTitle(name):
    title_group = {
        'mr' : 'Mr',
        'mrs' : 'Mrs',
        'miss' : 'Miss',
        'master' : 'Matser',
        'don' : 'Sir',
        'rev' : 'Sir',
        'dr' : 'Officer',
        'mme' : 'Mrs',
        'ms' : 'Mrs',
        'major' : 'Officer',
        'lady' : 'Lady',
        'sir' : 'Sir',
        'mlle' : 'Miss',
        'col' : 'Officer',
        'capt' : 'Officer',
        'the countess' : 'Lady',
        'jonkheer' : 'Sir',
        'dona' : 'Lady'
        
        
    }
    name_with_title = name.split(",")[1]
    title = name_with_title.split(".")[0]
    title = title.strip().lower()
    return title_group[title]
#create title Feature
df['Title'] = df.Name.map(lambda(x): GetTitle(x))
df.head()
#box plot Age with title
df[df.Age.notnull()].boxplot('Age', 'Title');
#replace missing values
title_age_median = df.groupby('Title').Age.transform('median')
df.Age.fillna(title_age_median, inplace=True)

#check info again
df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 1309 entries, 1 to 1309
Data columns (total 12 columns):
Survived    1309 non-null int64
Pclass      1309 non-null int64
Name        1309 non-null object
Sex         1309 non-null object
Age         1309 non-null float64
SibSp       1309 non-null int64
Parch       1309 non-null int64
Ticket      1309 non-null object
Fare        1309 non-null float64
Cabin       295 non-null object
Embarked    1309 non-null object
Title       1309 non-null object
dtypes: float64(2), int64(4), object(6)
memory usage: 172.9+ KB<jupyter_text>Working with outliers Age<jupyter_code>#use histogram to understand the distribution
df.Age.plot(kind = 'hist', bins=20, color= 'c')
df.loc[df.Age >70]<jupyter_output><empty_output><jupyter_text>Fare<jupyter_code>#historam for fare
df.Fare.plot(kind='hist', bins= 20)
#box plot to identify outliers
df.Fare.plot(kind='box');
#look into the outliers
df.loc[df.Fare == df.Fare.max()]
#try some transformation to reduce the skewness
LogFare = np.log(df.Fare + 1.0) #adding 1.0 to accomodate zero fare: log(0) undefined
LogFare.plot(kind = 'hist', bins=20, color='c')
#binnig
pd.qcut(df.Fare,4)
#qcut with label option
pd.qcut(df.Fare,4, labels=['very_low', 'low', 'high', 'very_high'])
pd.qcut(df.Fare,4, labels=['very_low', 'low', 'high', 'very_high']).value_counts().plot(kind='bar', color='c', rot=0)
#create fare bin feature
df['Fare_Bin'] = pd.qcut(df.Fare,4, labels=['very_low', 'low', 'high', 'very_high'])<jupyter_output><empty_output><jupyter_text>Feature Engineering  Feature Age State(child, Adult)<jupyter_code>#age state based on age
df['AgeState'] = np.where(df['Age'] >= 18, 'Adult', 'Child' )
#Age state value counts
df['AgeState'].value_counts()
#Age state cross tabs
pd.crosstab(df[df.Survived != -888].Survived, df[df.Survived != 888].AgeState)<jupyter_output><empty_output><jupyter_text>Feature: FamilySize<jupyter_code>#family size: Adding Parents with  siblings
df['FamilySize'] = df.Parch + df.SibSp + 1 #1 for self
#explore the family
df['FamilySize'].plot(kind='hist',color='c')
#further explore the family size with large family numbers
df.loc[df.FamilySize == df.FamilySize.max()]
pd.crosstab(df[df.Survived != -888].Survived, df[df.Survived != -888].FamilySize)<jupyter_output><empty_output><jupyter_text>Feature: IsMother<jupyter_code>df['IsMother'] = np.where(((df.Sex == 'female') & (df.Age >18) & (df.Parch > 0) & (df.Title != "Miss")),1,0)
#cross tab with is Mother
pd.crosstab(df[df.Survived != -888].Survived, df[df.Survived != -888].IsMother)<jupyter_output><empty_output><jupyter_text>Deck<jupyter_code>df.Cabin
df.Cabin.unique()
df.loc[df.Cabin == 'T']
#set cabin value T to nan
df.loc[df.Cabin == 'T', 'Cabin'] = np.nan
df.Cabin.unique()
#extract the first chancter of cabin informantion to deck
def get_deck(cabin):
    return np.where(pd.notnull(cabin), (str(cabin)[0]).upper(),'Z')
df['Deck'] = df['Cabin'].map(lambda x: get_deck(x))
#check counts
df.Deck.value_counts()
# use crosstab feature 
pd.crosstab(df[df.Survived != -888].Survived, df[df.Survived != -888].Deck)<jupyter_output><empty_output><jupyter_text>Categorical Feature Encoding<jupyter_code>df["IsMale"] = np.where(df.Sex == 'male', 1, 0)
#get Deck,Pclass, Title, AgeState
df = pd.get_dummies(df, columns=['Deck', 'Pclass', 'Title', 'Fare_Bin', 'Embarked', 'AgeState'])
df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 1309 entries, 1 to 1309
Data columns (total 39 columns):
Survived              1309 non-null int64
Name                  1309 non-null object
Sex                   1309 non-null object
Age                   1309 non-null float64
SibSp                 1309 non-null int64
Parch                 1309 non-null int64
Ticket                1309 non-null object
Fare                  1309 non-null float64
Cabin                 294 non-null object
FamilySize            1309 non-null int64
IsMother              1309 non-null int64
IsMale                1309 non-null int64
Deck_A                1309 non-null uint8
Deck_B                1309 non-null uint8
Deck_C                1309 non-null uint8
Deck_D                1309 non-null uint8
Deck_E                1309 non-null uint8
Deck_F                1309 non-null uint8
Deck_G                1309 non-null uint8
Deck_Z                1309 non-null uint8
Pclass_1              1309 non-null uint8
Pcla[...]<jupyter_text>Drop and Reorder columns<jupyter_code>df.drop(["Cabin","Name","Ticket","Parch","SibSp","Sex"], axis=1, inplace=True)
columns = [column for column in df.columns if column != 'Survived']
columns = ['Survived'] + columns
df = df[columns]
df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 1309 entries, 1 to 1309
Data columns (total 33 columns):
Survived              1309 non-null int64
Age                   1309 non-null float64
Fare                  1309 non-null float64
FamilySize            1309 non-null int64
IsMother              1309 non-null int64
IsMale                1309 non-null int64
Deck_A                1309 non-null uint8
Deck_B                1309 non-null uint8
Deck_C                1309 non-null uint8
Deck_D                1309 non-null uint8
Deck_E                1309 non-null uint8
Deck_F                1309 non-null uint8
Deck_G                1309 non-null uint8
Deck_Z                1309 non-null uint8
Pclass_1              1309 non-null uint8
Pclass_2              1309 non-null uint8
Pclass_3              1309 non-null uint8
Title_Lady            1309 non-null uint8
Title_Matser          1309 non-null uint8
Title_Miss            1309 non-null uint8
Title_Mr              1309 non-null uint8
Title_M[...]<jupyter_text>Save Processed Data Set<jupyter_code>#print os.path.pardir
processed_data_path = os.path.join(os.path.pardir,"data","processed")
write_train_path = os.path.join(processed_data_path,"train.csv")
write_test_path = os.path.join(processed_data_path, 'test.csv')
#train data
df.loc[df.Survived != -888].to_csv(write_train_path)
#test data
columns = [column for column in columns if column != "Survived"]
df.loc[df.Survived == -888, columns].to_csv(write_test_path)<jupyter_output><empty_output><jupyter_text>Building the data processing script<jupyter_code>get_processed_data_script_file = os.path.join(os.path.pardir,"src","data","get_processed_data.py")
%%writefile $get_processed_data_script_file
import numpy as np
import pandas as pd
import os

def read_data():
    raw_data_path = os.path.join(os.path.pardir,"data","raw")
    train_data = os.path.join(raw_data_path, "train.csv")
    test_data = os.path.join(raw_data_path, "test.csv")
    # read csv
    train_df = pd.read_csv(train_data, index_col="PassengerId")
    test_df = pd.read_csv(test_data, index_col="PassengerId")
    test_df["Survived"] = -888
    df = pd.concat((train_df, test_df), axis=0)
    return df

def processed_data(df):
    #using method chaining concept:
    return(df
       #create a title attribute
       .assign(Title= lambda x: x.Name.map(get_title))
       #working with missing value
       .pipe(fill_missing_value)
       #create fare bin feature
       .assign(Fare_Bin = lambda x: pd.qcut(x.Fare, 4, labels=['very_low', 'low', 'high', 'very_high'])) 
       # create Age state    
       .assign(AgeState= lambda x: np.where(x.Age >= 18, "Adult", "Child"))
       # Family size
       .assign(FamilySize = lambda x: x.Parch + x.SibSp + 1)
       .assign(IsMother = lambda x: np.where((x.Sex == 'female')&(x.Parch > 0) & (x.Age > 18) &(x.Title != 'Miss'), 1, 0))
       # create deck feature
       .assign(Cabin= lambda x: np.where(x.Cabin == 'T', np.nan, x.Cabin))
       .assign(Deck = lambda x: x.Cabin.map(get_deck))
       # feature encoding
       .assign(IsMale = lambda x: np.where(x.Sex == 'male', 1, 0))
       .pipe(pd.get_dummies, columns=['Deck', 'Pclass', 'Title', 'Fare_Bin', 'Embarked', 'AgeState'])
       #add code to drop unnecessary columns
       .drop(['Cabin', 'Name', 'Ticket', 'Parch', 'SibSp', 'Sex'], axis=1)
       # reorder columns
       .pipe(reorder_columns)    
      )
def get_title(name):
    title_group = {
        "mr": "Mr",
        'mrs': "Mrs",
        'miss': "Miss",
        'master': "Master",
        'don': "Sir",
        'rev': 'Sir',
        'dr': 'Officer',
        'mme': 'Mrs',
        'ms': 'Mrs',
        'major': 'Officer',
        'lady': 'Lady',
        'sir': 'Sir',
        'mlle': 'Miss',
        'col': 'Officer',
        'capt':'Officer',
        'the countess': 'Lady',
        'jonkheer': 'Sir',
        'dona': 'Lady'
    }
    first_name_with_title = name.split(",")[1]
    title = first_name_with_title.split(".")[0]
    title = title.strip().lower()
    return title_group[title]
def fill_missing_value(df):
    #emabrked
    df.Embarked.fillna('C', inplace=True)
    #fare
    median_fare = df[(df.Pclass == 3) & (df.Embarked == 'S')]["Fare"].median()
    df.Fare.fillna(median_fare, inplace=True)
    #age
    title_age_median = df.groupby("Title").Age.transform('median')
    df.Age.fillna(title_age_median, inplace=True)
    return df
def get_deck(cabin):
    return np.where(pd.notnull(cabin), (str(cabin)[0]).upper(), 'Z')

def reorder_columns(df):
    columns = [column for column in df.columns if column != 'Survived']
    columns = ['Survived'] + columns
    df = df[columns]
    return df

def write_data(df):
    processed_data_path = os.path.join(os.path.pardir,"data","processed")
    write_train_path = os.path.join(processed_data_path,"train.csv")
    write_test_path = os.path.join(processed_data_path, 'test.csv')
    #train data
    df[df.Survived != -888].to_csv(write_train_path)
    #test data
    columns = [column for column in df.columns if column != "Survived"]
    df[df.Survived == -888][columns].to_csv(write_test_path)
if __name__ == '__main__':
    df = read_data()
    df = processed_data(df)
    write_data(df)
!python $get_processed_data_script_file
train_df = pd.read_csv(write_train_path)
train_df.info()
test_df = pd.read_csv(write_test_path)
test_df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 418 entries, 0 to 417
Data columns (total 33 columns):
PassengerId           418 non-null int64
Age                   418 non-null float64
Fare                  418 non-null float64
FamilySize            418 non-null int64
IsMother              418 non-null int64
IsMale                418 non-null int64
Deck_A                418 non-null int64
Deck_B                418 non-null int64
Deck_C                418 non-null int64
Deck_D                418 non-null int64
Deck_E                418 non-null int64
Deck_F                418 non-null int64
Deck_G                418 non-null int64
Deck_Z                418 non-null int64
Pclass_1              418 non-null int64
Pclass_2              418 non-null int64
Pclass_3              418 non-null int64
Title_Lady            418 non-null int64
Title_Master          418 non-null int64
Title_Miss            418 non-null int64
Title_Mr              418 non-null int64
Title_Mrs             418 non-[...]<jupyter_text>Advanced visulization using MatPlotLib<jupyter_code>import matplotlib.pyplot as plt
%matplotlib inline
plt.hist(df.Age)
plt.hist(df.Age, bins= 20 ,color="C")
plt.show()
plt.hist(df.Age, bins=20,color="c")
plt.title("Histogram: Age")
plt.xlabel("Bins")
plt.ylabel("Counts")
plt.show()
f, ax = plt.subplots()
ax.hist(df.Age,bins=20,color='c')
ax.set_title("Histogram: Age")
ax.set_xlabel("Bins")
ax.set_ylabel("Counts")
plt.show()
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(14,3))
ax1.hist(df.Fare, bins=20, color='c')
ax1.set_title("Histogram:Fare")
ax1.set_xlabel("Bins")
ax1.set_ylabel("Counts")

ax2.hist(df.Age, bins=20, color='c')
ax2.set_title("Histogram:Age")
ax2.set_xlabel("Bins")
ax2.set_ylabel("Counts")
plt.show()

f, axis_arr = plt.subplots(3,2, figsize = (14,7))
axis_arr[0,0].hist(df.Fare, bins=20 ,color='c')
axis_arr[0,0].set_title("Histogram:Fare")
axis_arr[0,0].set_xlabel("Bins")
axis_arr[0,0].set_ylabel("Counts")

axis_arr[0,1].hist(df.Age, bins=20 ,color='tomato')
axis_arr[0,1].set_title("Histogram:Age")
axis_arr[0,1].set_xlabel("Bins")
axis_arr[0,1].set_ylabel("Counts")

axis_arr[1,0].boxplot(df.Fare.values)
axis_arr[1,0].set_title("Boxplot:Fare")
axis_arr[1,0].set_xlabel("Fare")
axis_arr[1,0].set_ylabel("Fare")

axis_arr[1,1].boxplot(df.Age.values)
axis_arr[1,1].set_title("Boxplot:Age")
axis_arr[1,1].set_xlabel("Age")
axis_arr[1,1].set_ylabel("Age")

axis_arr[2,0].scatter(df.Age, df.Fare, color='c', alpha=0.15)
axis_arr[2,0].set_title("Sctter Plot:Age vs Fare")
axis_arr[2,0].set_xlabel("Age")
axis_arr[2,0].set_ylabel("Fare")

axis_arr[2,1].axis('off')
plt.tight_layout()

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1462495618647038, 'fraction_numerical': 0.041929547844374346, 'mean_word_length': 3.9128282393456737, 'pattern_counts': {'":': 13, '<': 104, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '26', 'dir': 'jupyter-structured-clean-dedup', 'id': '402306', 'license': 'MIT', 'n_tokens_mistral': 9102, 'n_tokens_neox': 8290, 'n_words': 1874, 'path': 'notebooks/2.0-ak-exploring-exploring-processing-data.ipynb', 'repo_name': 'abhisheksunkuru/Titanic_data_science', 'size': '22824'}