Python Forum
ValueError: could not convert the string to float
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ValueError: could not convert the string to float
#1
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'
Reply
#2
Please use Code Tags.
You can edit your post.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#3
(Jun-14-2018, 07:31 AM)DeaD_EyE Wrote: Please use Code Tags.
You can edit your post.

done, any help appreciated.
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Sad ValueError: could not convert string to float badju 0 4,326 Jul-01-2021, 12:13 AM
Last Post: badju
  Indirectlty convert string to float in JSON file WBPYTHON 6 5,944 May-06-2020, 12:09 PM
Last Post: WBPYTHON
  ValueError: could not convert string to float RahulSingh 3 4,192 Apr-09-2020, 02:59 PM
Last Post: dinesh
  convert a list of string+bytes into a list of strings (python 3) pacscaloupsu 4 10,846 Mar-17-2020, 07:21 AM
Last Post: markfilan
  Convert dataframe string column to numeric in Python darpInd 1 2,300 Mar-14-2020, 10:07 AM
Last Post: ndc85430
  convert 'A B C' to numpy float matrix rezabma 4 2,550 Feb-27-2020, 09:48 AM
Last Post: rezabma
  ValueError: could not convert string to float: '4 AVENUE' Kudzo 4 5,931 Jan-26-2020, 10:47 PM
Last Post: Kudzo
  Convert 'object' to 'string' AdWill97 1 62,454 May-06-2019, 08:22 AM
Last Post: Yoriz
  Problema with convert image to string karlo123 1 2,774 May-16-2018, 10:44 PM
Last Post: karlo123
  Error: ValueError: could not convert string to float: 'L200 1.6 D/C' Jaarroy 2 6,563 Jan-18-2018, 02:00 PM
Last Post: Jaarroy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020