application_vnd.jupyter.stderr_output_1.png
import pandas as pd

train_set = pd.read_csv('train.csv')
test_set = pd.read_csv('test.csv')

def refine_title(title):
    if title in ['Mr.', 'Sir.', 'Major.', 'Dr.', 'Capt.']:
        return 'mr'
    elif title == 'Master.':
        return 'master'
    elif title in ['Miss.', 'Ms.']:
        return 'miss'
    elif title in ['Mrs.', 'Lady.']:
        return 'mrs'
    else:
        return 'other'

train_set['Title'] = train_set['Title'].apply(refine_title)