1、
参考:https://www.kaggle.com/kabure/titanic-eda-model-pipeline-keras-nn
#df_train.Age = df_train.Age.fillna(-0.5) #creating the intervals that we need to cut each range of ages interval = (0, 5, 12, 18, 25, 35, 60, 120) #Seting the names that we want use to the categorys cats = ['babies', 'Children', 'Teen', 'Student', 'Young', 'Adult', 'Senior'] # Applying the pd.cut and using the parameters that we created df_train["Age_cat"] = pd.cut(df_train.Age, interval, labels=cats)
2、
3、