title: Why does scaling then transforming my train data cause "ValueError: setting an array element with a sequence"?
body: <p>I have a CSV dataset with hourly time series information. I'm trying to create a model for forecasting using Long Short-Term Memory (LSTM) machine learning.</p>
  
  <p>I'm trying to scale train data using Sklearn's MinMax Scaler, then later, to transform the scale of the data using scale(). When tried, this returns: "<em>ValueError: setting an array element with a sequence</em>" and cites those two steps as part of the problem.</p>
  
  <p>Any ideas on how to solve this error in an LSTM problem?</p>
  
  <p>EDIT: looking elsewhere suggests the solution may involve uneven length of sequence inputs, but I'm still not clear how to fix that.</p>
  
  <p>Here is the code cited in the error (note 113 and 42).</p>
  
  <pre><code>from sklearn.preprocessing import MinMaxScaler
  
  39 # scale train and test data to [-1, 1]  
  40 def scale(train, test):
  41    scaler = MinMaxScaler(feature_range=(-1, 1))
  42    scaler = scaler.fit(train)
  
  ...
  
  112 # transform the scale of the data
  113 scaler, train_scaled, test_scaled = scale(train, test)
  </code></pre>
  
  <p>I've omitted several intermediate steps which I don't think are crucial, but perhaps I'm wrong. The error looks like this: </p>
  
  <pre><code>Using TensorFlow backend.
  Traceback (most recent call last):
    File "code.py", line 113, in &lt;module&gt;
     scaler, train_scaled, test_scaled = scale(train, test)
    File "code.py", line 42, in scale
     scaler = scaler.fit(train)
    File "C:\...\sklearn\preprocessing\data.py", line 325, in fit
     return self.partial_fit(X, y)
    File "C:\...\sklearn\preprocessing\data.py", line 353, in partial_fit
     force_all_finite="allow-nan")
    File "C:\...\sklearn\utils\validation.py", line 496, in check_array
     array = np.asarray(array, dtype=dtype, order=order)
    File "C:\...\numpy\core\numeric.py", line 538, in asarray
     return array(a, dtype, copy=False, order=order)
  ValueError: setting an array element with a sequence.
  </code></pre>
  
  <p>By best guess on why the code works for the guide template and not my code is that the guide I'm working from is only two columns (date and a number)...</p>
  
  <pre><code>"Month","Sales"
  "1-01",266.0
  "1-02",145.9
  "1-03",183.1
  "1-04",119.3
  </code></pre>
  
  <p>while my CSV has four columns (timestamp and three numbers):</p>
  
  <pre><code>timeStamp              demand   precip  temp
  2012-01-01  00:00:00    4937.5  0       46.13
  2012-01-01  01:00:00    4752.1  0       45.89
  2012-01-01  02:00:00    4542.6  0.01    45.04
  2012-01-01  03:00:00    4357.7  0       45.03
  </code></pre>
  
  <p>But ultimately, I'm new to ML and lost.</p>