i'm getting the following error. i don't know why
ValueError Traceback (most recent call last)
<ipython-input-70-47db790ecefc> in <module>
2 #Y = train_label.to_numpy()
3
----> 4 logreg = LogisticRegression().fit(train_X, train_Y)
4 frames
/usr/local/lib/python3.7/dist-packages/pandas/core/generic.py in __array__(self, dtype)
1991
1992 def __array__(self, dtype: NpDtype | None = None) -> np.ndarray:
-> 1993 return np.asarray(self._values, dtype=dtype)
1994
1995 def __array_wrap__(
ValueError: could not convert string to float: '"840343879668908032"'
this is the code i tried to execute
X = train_attr.to_numpy()
Y = train_label.to_numpy()
logreg = LogisticRegression().fit(train_X, train_Y)
CodePudding user response:
you have additional quotation marks in the string that you are trying to convert to float.
CodePudding user response:
The string you are trying to convert is this
"840343879668908032"
but it should be this
840343879668908032
Python is taking double quotes as a part of the string, This may be because you would have used quotes multiple time like this
sample_str = '"840343879668908032"'
or
sample_str2 = '"1321351"'
so you should remove the additional quotes and for example do
sample_str = '840343879668908032'