df = X_train_raw.copy() # Add a column to determine if the person can vote df['can_vote'] = df['Age'].apply(lambda age: 1 if age >= 18 else 0) # 892 passengers can vote; aka they are 18 or older df['can_vote'].value_counts() # Cabin letter: a cabin can be denoted as B123. The cabin letter will be B. df.loc[:, 'cabin_letter'] = df['Cabin'].apply( lambda cabin: cabin[0] if cabin and type(cabin) is str else None, )