title: efficiently passing dataframes as y and X to scikit-learn fits
body: <p>I generate a pandas dataframe from <code>read_sql_query</code>.  It has three columns, "results, speed, weight"</p>
  
  <p>I want to use scikit-learn <code>LinearRegression</code> to fit <code>results = f(speed, weight)</code></p>
  
  <p>I haven't been able to find the correct syntax that would allow me to pass this dataframe, or column slices of it, to <code>LinearRegression.fit(y, X)</code>.  </p>
  
  <pre><code>print df['result'].shape
  print df[['speed', 'weight']].shape
  (8L,)
  (8, 2)
  </code></pre>
  
  <p>but I cannot pass that to <code>fit</code></p>
  
  <pre><code>lm.fit(df['result'], df[['speed', 'weight']])
  </code></pre>
  
  <p>It throws a <code>deprecation warning</code> and a <code>ValueError</code></p>
  
  <pre><code>DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19. 
  ValueError: Found arrays with inconsistent numbers of samples: [1 8]
  </code></pre>
  
  <p>What is the efficient, clean way to take dataframes of targets and features, and pass them to <code>fit</code> operations?</p>
  
  <p>This is how I generated the example:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  from datetime import datetime, timedelta
  
  date_today = datetime.now()
  days = pd.date_range(date_today, date_today + timedelta(7), freq='D')
  
  np.random.seed(seed=1111)
  data = np.random.randint(1, high=100, size=len(days))
  data2 = np.random.randint(1, high=100, size=len(days))
  data3 = np.random.randint(1, high=100, size=len(days))
  df = pd.DataFrame({'test': days, 'result': data,'speed': data2,'weight': data3})
  df = df.set_index('test')
  print(df)
  </code></pre>