text_plain_output_1.png
import pandas as pd # data processing

train_data = pd.read_csv('/kaggle/input/titanic/train.csv')
test_data = pd.read_csv('/kaggle/input/titanic/test.csv')

train_data.isna().sum()

train_data = train_data.drop(labels=['Cabin'], axis='columns')
test_data = test_data.drop(labels=['Cabin'], axis='columns')

train_data.shape

train_data.isna().sum()

test_data.isna().sum()

train_data.sample(10)

Ticket1 = []
TicketNumber1 = []
TicketNumber2 = []
for i in list(train_data.Ticket):
    if not i.isdigit():
        Ticket1.append(i.replace('.', '').replace('/', '').strip().split(' ')[0])
    else:
        Ticket1.append('X')
        TicketNumber1.append(0)
train_data['Ticket'] = Ticket1
Ticket2 = []
for j in list(test_data.Ticket):
    if not j.isdigit():
        Ticket2.append(j.replace('.', '').replace('/', '').strip().split(' ')[0])
    else:
        Ticket2.append('X')
test_data['Ticket'] = Ticket2

print(train_data['Ticket'].unique())
print(test_data['Ticket'].unique())