@@ -57,7 +57,7 @@ Normally you'll read the data from a file, but for demonstration purposes we'll
5757
5858 >>> data = pd.DataFrame({'pet': ['cat', 'dog', 'dog', 'fish', 'cat', 'dog', 'cat', 'fish'],
5959 ... 'children': [4., 6, 3, 3, 2, 3, 5, 4],
60- ... 'salary': [90, 24, 44, 27, 32, 59, 36, 27]})
60+ ... 'salary': [90. , 24, 44, 27, 32, 59, 36, 27]})
6161
6262Transformation Mapping
6363----------------------
@@ -106,7 +106,7 @@ Now that the transformation is trained, we confirm that it works on new data::
106106
107107 >>> sample = pd.DataFrame({'pet': ['cat'], 'children': [5.]})
108108 >>> np.round(mapper.transform(sample), 2)
109- array([[ 1. , 0. , 0. , 1.04]])
109+ array([[1. , 0. , 0. , 1.04]])
110110
111111
112112Output features names
@@ -251,14 +251,14 @@ Only columns that are listed in the DataFrameMapper are kept. To keep a column b
251251 ... ('children', None)
252252 ... ])
253253 >>> np.round(mapper3.fit_transform(data.copy()))
254- array([[ 1., 0., 0., 4.],
255- [ 0., 1., 0., 6.],
256- [ 0., 1., 0., 3.],
257- [ 0., 0., 1., 3.],
258- [ 1., 0., 0., 2.],
259- [ 0., 1., 0., 3.],
260- [ 1., 0., 0., 5.],
261- [ 0., 0., 1., 4.]])
254+ array([[1., 0., 0., 4.],
255+ [0., 1., 0., 6.],
256+ [0., 1., 0., 3.],
257+ [0., 0., 1., 3.],
258+ [1., 0., 0., 2.],
259+ [0., 1., 0., 3.],
260+ [1., 0., 0., 5.],
261+ [0., 0., 1., 4.]])
262262
263263Applying a default transformer
264264******************************
@@ -329,11 +329,11 @@ Then the following code could be used to override default imputing strategy:
329329 ... ' col3' : [0 , 0 , 0 , None , None ]
330330 ... })
331331 >>> mapper6.fit_transform(data6)
332- array([[ 1., 1., 0.],
333- [ 1., 0., 0.],
334- [ 1., 1., 0.],
335- [ 2., 1., 0.],
336- [ 3., 1., 0.]])
332+ array([[1., 1., 0.],
333+ [1., 0., 0.],
334+ [1., 1., 0.],
335+ [2., 1., 0.],
336+ [3., 1., 0.]])
337337
338338
339339Feature selection and other supervised transformations
@@ -344,14 +344,14 @@ Feature selection and other supervised transformations
344344 >>> from sklearn.feature_selection import SelectKBest, chi2
345345 >>> mapper_fs = DataFrameMapper([([' children' ,' salary' ], SelectKBest(chi2, k = 1 ))])
346346 >>> mapper_fs.fit_transform(data[[' children' ,' salary' ]], data[' pet' ])
347- array([[ 90.],
348- [ 24.],
349- [ 44.],
350- [ 27.],
351- [ 32.],
352- [ 59.],
353- [ 36.],
354- [ 27.]])
347+ array([[90.],
348+ [24.],
349+ [44.],
350+ [27.],
351+ [32.],
352+ [59.],
353+ [36.],
354+ [27.]])
355355
356356Working with sparse features
357357****************************
0 commit comments