Kaggle competition: PUBG Finish Placement Prediction (Kernels Only)
temp['Initick'] = 0
for s in temp:
temp['Initick']=temp.Ticket.str.extract('^([A-Za-z]+)')
 for s in temp:
temp.loc[(temp.Initick.isnull()),'Initick']='X'
temp.head()<feature_engineering>
sub = pd.read_csv('.. /input/submission2/submission.csv')
 sub.to_csv('practice1.csv',index=False )
train['Tgroup'] = 0
temp['Tgroup'] = 0
temp.loc[(temp['Initick']=='X')&(temp['Pclass']==1),'Tgroup']= 1
temp.loc[(temp['Initick']=='X')&(temp['Pclass']==2),'Tgroup']= 2
temp.loc[(temp['Initick']=='X')&(temp['Pclass']==3),'Tgroup']= 3
temp.loc[(temp['Initick']=='Fa'),'Tgroup']= 3
temp.loc[(temp['Initick']=='SCO'),'Tgroup']= 4
temp.loc[(temp['Initick']=='A'),'Tgroup']= 5
temp.loc[(temp['Initick']=='CA'),'Tgroup']= 6
temp.loc[(temp['Initick']=='W'),'Tgroup']= 7
temp.loc[(temp['Initick']=='S'),'Tgroup']= 8
temp.loc[(temp['Initick']=='SOTON'),'Tgroup']= 9
temp.loc[(temp['Initick']=='LINE'),'Tgroup']= 10
temp.loc[(temp['Initick']=='STON'),'Tgroup']= 11
temp.loc[(temp['Initick']=='C'),'Tgroup']= 12
temp.loc[(temp['Initick']=='P'),'Tgroup']= 13
temp.loc[(temp['Initick']=='WE'),'Tgroup']= 14
temp.loc[(temp['Initick']=='SC'),'Tgroup']= 15
temp.loc[(temp['Initick']=='F'),'Tgroup']= 16
temp.loc[(temp['Initick']=='PP'),'Tgroup']= 17
temp.loc[(temp['Initick']=='PC'),'Tgroup']= 17
temp.loc[(temp['Initick']=='SO'),'Tgroup']= 18
temp.loc[(temp['Initick']=='SW'),'Tgroup']= 19 
<groupby>
sub = pd.read_csv('.. /input/pleasetry1/sub1.csv')
 sub.to_csv('sub1.csv',index=False )
groupmean('Tgroup', 'Survived' )<feature_engineering>
import numpy as np
import pandas as pd
temp['Fgroup']=0
temp.loc[temp['Fare']<= 7.125,'Fgroup']=5.0
temp.loc[(temp['Fare']>7.125)&(temp['Fare']<=7.9),'Fgroup']= 7.5
temp.loc[(temp['Fare']>7.9)&(temp['Fare']<=8.03),'Fgroup']= 8.0
temp.loc[(temp['Fare']>8.03)&(temp['Fare']<10.5),'Fgroup']= 9.5
temp.loc[(temp['Fare']>=10.5)&(temp['Fare']<23.0),'Fgroup']= 16.0
temp.loc[(temp['Fare']>=23.0)&(temp['Fare']<=27.8),'Fgroup']= 25.5
temp.loc[(temp['Fare']>27.8)&(temp['Fare']<=51.0),'Fgroup']= 38.0
temp.loc[(temp['Fare']>51.0)&(temp['Fare']<=73.5),'Fgroup']= 62.0
temp.loc[temp['Fare']>73.5,'Fgroup']= 100.0<count_values>
sub = pd.read_csv('.. /input/pleasetry1/sub1.csv')
 sub.to_csv('sub1.csv',index=False )
temp.Cabin.value_counts()<count_missing_values>
import numpy as np
import pandas as pd
temp.Cabin.isnull().sum()<feature_engineering>
sub = pd.read_csv('.. /input/pleasetry2/sub2.csv')
 sub.to_csv('sub2.csv',index=False )
temp['Inicab'] = 0
for i in temp:
temp['Inicab']=temp.Cabin.str.extract('^([A-Za-z]+)')
 temp.loc[(( temp.Cabin.isnull())&(temp.Pclass.values == 1)) ,'Inicab']='X'
temp.loc[(( temp.Cabin.isnull())&(temp.Pclass.values == 2)) ,'Inicab']='Y'
temp.loc[(( temp.Cabin.isnull())&(temp.Pclass.values == 3)) ,'Inicab']='Z' 
<count_values>
import numpy as np
import pandas as pd
temp.Inicab.value_counts()<categorify>
sub = pd.read_csv('.. /input/pleasetry3/sub3.csv')
 sub.to_csv('sub3.csv',index=False )
temp['Inicab'].replace(['A','B', 'C', 'D', 'E', 'F', 'G','T', 'X', 'Y', 'Z'],[1,2,3,4,5,6,7,8,9,10,11],inplace=True )<filter>
import numpy as np
import pandas as pd
temp.loc[(temp.Embarked.isnull())]<filter>
sub = pd.read_csv('.. /input/pleasetry4/sub3.csv')
 sub.to_csv('sub4.csv',index=False )
temp.loc[(temp.Ticket == '113572')]<sort_values>
import numpy as np
import pandas as pd
temp.sort_values(['Ticket'], ascending = True)[35:45]<feature_engineering>
sub = pd.read_csv('.. /input/pleasetry5/sub5.csv')
 sub.to_csv('sub5.csv',index=False )
temp.loc[(train.Embarked.isnull()),'Embarked']='S'<sort_values>
import numpy as np
import pandas as pd
temp.sort_values(['Ticket'], ascending = True)[35:45]<groupby>
sub = pd.read_csv('.. /input/pleasetry6/sub5.csv')
 sub.to_csv('sub5.csv',index=False )
temp.groupby('Initial' ).Survived.mean()<categorify>
import numpy as np
import pandas as pd
temp['Initial'].replace(['Capt', 'Col', 'Countess', 'Don', 'Dona' , 'Dr', 'Jonkheer', 'Lady', 'Major', 'Master', 'Miss' ,'Mlle', 'Mme', 'Mr', 'Mrs', 'Ms', 'Rev', 'Sir'],[1, 2, 3, 4, 5, 6, 4, 3, 2, 8, 9, 3, 3, 4, 5, 3, 1, 3 ],inplace=True )<groupby>
sub = pd.read_csv('.. /input/lastTry1/sub6.csv')
 sub.to_csv('sub6.csv',index=False )
temp.groupby('Initial' ).Survived.mean()<groupby>
sub = pd.read_csv('.. /input/lasttry1/sub6.csv')
 sub.to_csv('sub6.csv',index=False )
temp.groupby('Embarked' ).Survived.mean()<categorify>
sub = pd.read_csv('.. /input/lasttry1/sub6_avg.csv')
 sub.to_csv('sub6_avg.csv',index=False )