Apply StandardScaler to parts of a data set
<p>I want to use <code>sklearn</code>'s <code>StandardScaler</code>. Is it possible to apply it to some feature columns but not others?</p>

<p>For instance, say my <code>data</code> is:</p>

<pre><code>data = pd.DataFrame({'Name' : [3, 4,6], 'Age' : [18, 92,98], 'Weight' : [68, 59,49]})

   Age  Name  Weight
0   18     3      68
1   92     4      59
2   98     6      49


col_names = ['Name', 'Age', 'Weight']
features = data[col_names]
</code></pre>

<p>I fit and transform the <code>data</code></p>

<pre><code>scaler = StandardScaler().fit(features.values)
features = scaler.transform(features.values)
scaled_features = pd.DataFrame(features, columns = col_names)

       Name       Age    Weight
0 -1.069045 -1.411004  1.202703
1 -0.267261  0.623041  0.042954
2  1.336306  0.787964 -1.245657
</code></pre>

<p>But of course the names are not really integers but strings and I don't want to standardize them. How can I apply the <code>fit</code> and <code>transform</code> methods only on the columns <code>Age</code> and <code>Weight</code>?</p>