You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to call preprocessing.scale on a pandas.Series instance, an error is thrown with scikit-learn version 0.20.0. Version 0.19.1. works just fine. The documentation states that the input to preprocessing.scale can be "array-like", and pandas.Series should fulfill this requirement since it is a "one-dimensional ndarray".
This should be the output (as it is in version 0.19.1):
[-1.22474487, 0. , 1.22474487]
A workaround is replacing preprocessing.scale(s) with preprocessing.scale([i for i in s]), which also yields this output.
Actual Results
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-16-ef1d298414c3> in <module>
3
4 s = pd.Series([1.0, 2.0, 3.0])
----> 5 preprocessing.scale(s)
~\anaconda3\envs\tensorflow\lib\site-packages\sklearn\preprocessing\data.py in scale(X, axis, with_mean, with_std, copy)
143 X = check_array(X, accept_sparse='csc', copy=copy, ensure_2d=False,
144 warn_on_dtype=True, estimator='the scale function',
--> 145 dtype=FLOAT_DTYPES, force_all_finite='allow-nan')
146 if sparse.issparse(X):
147 if with_mean:
~\anaconda3\envs\tensorflow\lib\site-packages\sklearn\utils\validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
594
595 if (warn_on_dtype and dtypes_orig is not None and
--> 596 {array.dtype} != set(dtypes_orig)):
597 # if there was at the beginning some other types than the final one
598 # (for instance in a DataFrame that can contain several dtypes) then
TypeError: iteration over a 0-d array
Description
When trying to call
preprocessing.scale
on apandas.Series
instance, an error is thrown with scikit-learn version 0.20.0. Version 0.19.1. works just fine. The documentation states that the input topreprocessing.scale
can be "array-like", andpandas.Series
should fulfill this requirement since it is a "one-dimensional ndarray".Steps/Code to Reproduce
Expected Results
This should be the output (as it is in version 0.19.1):
A workaround is replacing
preprocessing.scale(s)
withpreprocessing.scale([i for i in s])
, which also yields this output.Actual Results
Versions
The text was updated successfully, but these errors were encountered: