title: How to use Imputer in a DataFrameMapper on a dataframe?
body: <p>I want to use DataFrameMapper Imputer+Scaler mapping on all float64 columns of a dataframe. My code works with the StandardScaler but when I add the Imputer the mapper returns just one row with all zeros.</p>
  
  <p>I saw this question 
  <a href="https://stackoverflow.com/questions/38584184/imputer-on-some-dataframe-columns-in-python">Imputer on some Dataframe columns in Python</a> and the tutorial <a href="https://github.com/paulgb/sklearn-pandas" rel="nofollow noreferrer">https://github.com/paulgb/sklearn-pandas</a> And there is a warning: </p>
  
  <blockquote>
    <p>site-packages\sklearn\utils\validation.py:386: DeprecationWarning:
    Passing 1d arrays as data is deprecated in 0.17 and willraise
    ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if
    your data has a single feature or X.reshape(1, -1) if it contains a
    single sample.</p>
  </blockquote>
  
  <p>So I understand that there is a shape mismatch. How should the below example dataframe be reshaped? </p>
  
  <pre><code>import pandas as pd
  import numpy as np 
  from sklearn_pandas import DataFrameMapper
  from sklearn.preprocessing import StandardScaler, Imputer
  
  # just a random dataframe from http://pandas.pydata.org/pandas-docs/stable/10min.html
  dates = pd.date_range('20130101', periods=6)
  df = pd.DataFrame(np.random.randn(6,4), index=dates, columns=list('ABCD'))
  
  print "Starting with a random dataframe of 6 rows and 4 columns of floats:"
  print df.shape
  print df
  
  mapping=[('A', [Imputer(), StandardScaler()]), ('C', [Imputer(), StandardScaler()])]
  mapper = DataFrameMapper(mapping)
  
  result = mapper.fit_transform(df)
  
  print "I get an unexpected result of all zeroes in just one row."
  print result.shape
  print result
  
  print "Expected is a dataframe of 2 columns and 6 rows of scaled floats."
  print "something like this:"
  
  mapping=[('A', [StandardScaler()]), ('C', [StandardScaler()])]
  mapper = DataFrameMapper(mapping)
  
  result_scaler = mapper.fit_transform(df)
  print result_scaler.shape
  print result_scaler
  </code></pre>
  
  <p>This the output</p>
  
  <pre><code>Starting with a random dataframe of 6 rows and 4 columns of floats.
  (6, 4)
                     A         B         C         D
  2013-01-01 -0.070551  0.039074  0.513491 -0.830585
  2013-01-02 -0.313069 -1.028936  2.359338 -0.830518
  2013-01-03 -1.264926 -0.830575  0.461515  0.427228
  2013-01-04 -0.374400  0.619986  0.318128  0.361712
  2013-01-05 -0.235587 -1.647786 -0.819940 -1.036435
  2013-01-06  1.436073  0.312183  1.566990 -0.272224
  Unexpected result is all zeroes in just one row.
  (1L, 12L)
  [[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]]
  Expected is a dataframe of 2 columns and 6 rows of scaled floats.
  something like this
  (6L, 2L)
  [[ 0.08306789 -0.21892275]
   [-0.21975387  1.61986719]
   [-1.40829622 -0.27069922]
   [-0.29633508 -0.4135387 ]
   [-0.12300572 -1.54725542]
   [ 1.964323    0.83054889]]
  </code></pre>
  
  <p>And a followup question - my original dataframe is a combination of floats, booleans and objects (labels). So when I have a list of </p>
  
  <pre><code>floats = list(df.select_dtypes(include=['float64']).columns)
  mapping=[(f, [Imputer(missing_values=0,strategy="mean"), StandardScaler()]) for f in floats]
  </code></pre>
  
  <p>how could I prepare the dataframe (shape it for Imputer) just for those columns?</p>