@@ -38,19 +38,18 @@ test = pd.read_csv("http://s3.amazonaws.com/assets.datacamp.com/course/Kaggle/te
38
38
39
39
*** =sample_code
40
40
` ` ` {python}
41
- #Import the Numpy library
41
+ # Import the Numpy library
42
42
43
- #Import 'tree' from scikit-learn library
43
+ # Import 'tree' from scikit-learn library
44
44
from sklearn
45
-
46
45
` ` `
47
46
48
47
*** =solution
49
48
` ` ` {python}
50
- #Import the Numpy library
49
+ # Import the Numpy library
51
50
import numpy as np
52
51
53
- #Import 'tree' from scikit-learn library
52
+ # Import 'tree' from scikit-learn library
54
53
from sklearn import tree
55
54
` ` `
56
55
@@ -91,18 +90,17 @@ import numpy as np
91
90
from sklearn import tree
92
91
train = pd.read_csv("http://s3.amazonaws.com/assets.datacamp.com/course/Kaggle/train.csv")
93
92
test = pd.read_csv("http://s3.amazonaws.com/assets.datacamp.com/course/Kaggle/test.csv")
94
-
95
93
` ` `
96
94
97
95
*** =sample_code
98
96
` ` ` {python}
99
- #Convert the male and female groups to integer form
97
+ # Convert the male and female groups to integer form
100
98
train["Sex"][train["Sex"] == "male"] = 0
101
99
102
- #Impute the Embarked variable
100
+ # Impute the Embarked variable
103
101
train["Embarked"] =
104
102
105
- #Convert the Embarked classes to integer form
103
+ # Convert the Embarked classes to integer form
106
104
train["Embarked"][train["Embarked"] == "S"] = 0
107
105
108
106
#Print the Sex and Embarked columns
@@ -111,19 +109,19 @@ train["Embarked"][train["Embarked"] == "S"] = 0
111
109
112
110
*** =solution
113
111
` ` ` {python}
114
- #Convert the male and female groups to integer form
112
+ # Convert the male and female groups to integer form
115
113
train["Sex"][train["Sex"] == "male"] = 0
116
114
train["Sex"][train["Sex"] == "female"] = 1
117
115
118
- #Impute the Embarked variable
116
+ # Impute the Embarked variable
119
117
train["Embarked"] = train["Embarked"].fillna("S")
120
118
121
- #Convert the Embarked classes to integer form
119
+ # Convert the Embarked classes to integer form
122
120
train["Embarked"][train["Embarked"] == "S"] = 0
123
121
train["Embarked"][train["Embarked"] == "C"] = 1
124
122
train["Embarked"][train["Embarked"] == "Q"] = 2
125
123
126
- #Print the Sex and Embarked columns
124
+ # Print the Sex and Embarked columns
127
125
print(train["Sex"])
128
126
print(train["Embarked"])
129
127
` ` `
0 commit comments