text_plain_output_1.png
import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

df = pd.read_csv('../input/titanic/train.csv')
df1 = pd.read_csv('../input/titanic/train.csv')

df['Age'] = df['Age'].fillna(df['Age'].median())

df.dtypes

df['Sex'].value_counts()

l2 = df['Name']
l2_num = []
l5 = []
for i in l2:
    l3 = i.split(',')
    s = l3[-1]
    l4 = s.split('.')
    s1 = l4[0]
    l5.append(s1)
    if s1 == ' Mr':
        l2_num.append(1)
    elif s1 == ' Miss':
        l2_num.append(2)
    elif s1 == ' Mrs':
        l2_num.append(3)
    elif s1 == ' Master':
        l2_num.append(4)
    else:
        l2_num.append(5)
df['Title'] = l5
df['Title_num'] = l2_num
print(df['Title_num'].value_counts())
print(df['Title'].value_counts())