Python Forum
ValueError: could not convert the string to float - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: ValueError: could not convert the string to float (/thread-10936.html)



ValueError: could not convert the string to float - Grin - Jun-13-2018

Any help much appreciated:

from sklearn import preprocessing
btc.dropna(inplace=True)
X=btc.drop('Price_After_Month',axis=1)
X=preprocessing.scale(X)
y=btc['Price_After_Month']
Error:
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-48-fa0b50790240> in <module>() 2 btc.dropna(inplace=True) 3 X=btc.drop('Price_After_Month',axis=1) ----> 4 X=preprocessing.scale(X) 5 y=btc['Price_After_Month'] ~/.local/lib/python3.5/site-packages/sklearn/preprocessing/data.py in scale(X, axis, with_mean, with_std, copy) 131 X = check_array(X, accept_sparse='csc', copy=copy, ensure_2d=False, 132 warn_on_dtype=True, estimator='the scale function', --> 133 dtype=FLOAT_DTYPES) 134 if sparse.issparse(X): 135 if with_mean: ~/.local/lib/python3.5/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator) 431 force_all_finite) 432 else: --> 433 array = np.array(array, dtype=dtype, order=order, copy=copy) 434 435 if ensure_2d: ValueError: could not convert string to float: 'bitcoin'



RE: ValueError: could not convert the string to float - DeaD_EyE - Jun-14-2018

Please use Code Tags.
You can edit your post.


RE: ValueError: could not convert the string to float - Grin - Jun-14-2018

(Jun-14-2018, 07:31 AM)DeaD_EyE Wrote: Please use Code Tags.
You can edit your post.

done, any help appreciated.


RE: ValueError: could not convert the string to float - killerrex - Jun-14-2018

Check your input file or result of a request.
Numpy is expecting a list of float values and have found the string "bitcoin"...
The problem is in the sklearn code, so you must check if there is a new version of the module or something you shall call to initialise.