title: Using Keras StandardScaler with Groupby function in Pandas
body: <p>I have a pandas data frame with multiple columns. I need to use groupby function on each column and after use Keras StandardScaler function to transform each column in the dataframe. I tried the following code:</p>
  <pre><code>from sklearn.preprocessing import StandardScaler
  scaler=StandardScaler()
  df2= df.groupby('Sector').apply(lambda x: scaler.fit_transform(x.astype(float)))
  </code></pre>
  <p>but it returns lists of data by group, however, I need to preserve the initial structure of the dataframe.</p>
  <p>I specifically need to use StandardScaler because afterwards I want to use it to transform testing features.</p>
  <p>Is there a way to use StandardScaler in this case?</p>