Python/sklearn - preprocessing.MinMaxScaler 1d deprecation
<p>I'd like to scale a column of a dataframe to have values between 0 and 1. For this I'm using a <code>MinMaxScaler</code>, which works fine, but is sending me mixed messages. I'm doing:</p>

<pre><code>x = df['Activity'].values #returns a numpy array
min_max_scaler = preprocessing.MinMaxScaler()
x_scaled = min_max_scaler.fit_transform(x)
df['Activity'] = pd.Series(x_scaled)
</code></pre>

<p>Message numero uno for this code is a warning:</p>

<p><code>DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise 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.</code></p>

<p>Okay, so apparentyl having 1d arrays is gonna be a no-no soon, so let's try to reshape it as advised:</p>

<pre><code>x = df['Activity'].values.reshape(-1, 1)
</code></pre>

<p>Now the code doesn't even run: <code>Exception: Data must be 1-dimensional</code> is thrown. So I'm confused. 1d is going to be deprecated soon, but the data also has to be 1d?? How to do this safely? What's the issue here?</p>

<p><strong>EDIT as requested by @sascha</strong></p>

<p><code>x</code> looks like this:  </p>

<pre><code>array([ 0.00568953,  0.00634314,  0.00718003, ...,  0.01976002,
        0.00575024,  0.00183782])
</code></pre>

<p>And after reshaping:</p>

<pre><code>array([[ 0.00568953],
       [ 0.00634314],
       [ 0.00718003],
       ..., 
       [ 0.01976002],
       [ 0.00575024],
       [ 0.00183782]])
</code></pre>

<p>The whole warning:</p>

<pre><code>/usr/local/lib/python3.5/dist-packages/sklearn/preprocessing/data.py:321: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise 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.
  warnings.warn(DEPRECATION_MSG_1D, DeprecationWarning)
/usr/local/lib/python3.5/dist-packages/sklearn/preprocessing/data.py:356: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise 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.
  warnings.warn(DEPRECATION_MSG_1D, DeprecationWarning)
</code></pre>

<p>The error when I reshape:</p>

<pre><code>---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
&lt;ipython-input-132-df180aae2d1a&gt; in &lt;module&gt;()
      2 min_max_scaler = preprocessing.MinMaxScaler()
      3 x_scaled = min_max_scaler.fit_transform(x)
----&gt; 4 telecom['Activity'] = pd.Series(x_scaled)

/usr/local/lib/python3.5/dist-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath)
    225             else:
    226                 data = _sanitize_array(data, index, dtype, copy,
--&gt; 227                                        raise_cast_failure=True)
    228 
    229                 data = SingleBlockManager(data, index, fastpath=True)

/usr/local/lib/python3.5/dist-packages/pandas/core/series.py in _sanitize_array(data, index, dtype, copy, raise_cast_failure)
   2918     elif subarr.ndim &gt; 1:
   2919         if isinstance(data, np.ndarray):
-&gt; 2920             raise Exception('Data must be 1-dimensional')
   2921         else:
   2922             subarr = _asarray_tuplesafe(data, dtype=dtype)

Exception: Data must be 1-dimensional
</code></pre>