You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add documentation about using multiple transformers for the same column, as well as some caveats about passing a list or a simple string as columns selector.
Copy file name to clipboardExpand all lines: README.rst
+27-2
Original file line number
Diff line number
Diff line change
@@ -60,13 +60,23 @@ Transformation Mapping
60
60
Map the Columns to Transformations
61
61
**********************************
62
62
63
-
The mapper takes a list of pairs. The first is a column name from the pandas DataFrame (or a list of multiple columns, as we will see later). The second is an object which will perform the transformation which will be applied to that column::
63
+
The mapper takes a list of pairs. The first is a column name from the pandas DataFrame, or a list containing one or multiple columns (we will see an example with multiple columns later). The second is an object which will perform the transformation which will be applied to that column::
The difference between specifying the column selector as `'column'` (as a simple stirng) and `['column']` (as a list with one element) is the shape of the array that is passed to the transformer. In the first case, a one dimensional array with be passed, while in the second case it will be a 2-dimensional array with one column, i.e. a column vector.
71
+
72
+
This behaviour mimics the same pattern as pandas' dataframes `__getitem__` indexing:
73
+
74
+
>>> data['children'].shape
75
+
(8,)
76
+
>>> data[['children']].shape
77
+
(8, 1)
78
+
79
+
Be aware that some transformers expect a 1-dimensional input (the label-oriented ones) while some others, like `OneHotEncoder` or `Imputer`, expect 2-dimensional input, with the shape `[n_samples, n_features]`.
70
80
71
81
Test the Transformation
72
82
***********************
@@ -112,6 +122,21 @@ Now running ``fit_transform`` will run PCA on the ``children`` and ``salary`` co
112
122
[ -6.4],
113
123
[-15.4]])
114
124
125
+
Multiple transformers for the same column
126
+
*****************************************
127
+
128
+
Multiple transformers can be applied to the same column specifying them
0 commit comments