import pandas from numpy import array from sklearn preprocessing impor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import pandas
from numpy import array
from sklearn.preprocessing import Imputer
df = pandas.read_csv('train.csv', delimiter=',', header=None)
X, Y = array([x[2:] for x in df.values]), array([0 if y[1] == 'm' else 1 for y in df.values])
mising_pross = [imp = Imputer(missing_values='NaN', strategy='mean', axis=0)]
imp.fit(X, Y)
X_p = imp.transform(X)