问题描述
对于当前的项目,我计划在包含数字数据的CSV集合上运行scikit-learn随机梯度助推器算法.
For a current project, I am planning to run a scikit-learn Stochastic Graduent Booster algorithm over a CSV set that includes numerical data.
当调用脚本的 sgbr.fit(X_train,y_train)
行时,我收到了 ValueError:无法将字符串转换为float:
,没有更多详细信息在无法格式化的相应区域上给出.
When calling line sgbr.fit(X_train, y_train)
of the script, I am however receiving a ValueError: could not convert string to float:
with no further details given on the respective area that cannot be formatted.
我认为此错误与Python代码本身无关,而与CSV输入有关.但是,我已经检查了CSV文件,以确认所有部分都专门包含浮点数:
I assume that this error is not related to the Python code itself but rather the CSV input. I have however already checked the CSV file to confirm all sections exclusively include floats:
有人知道为什么 ValueError
会在没有位置指示的情况下出现吗?
Does anyone have an idea why the ValueError
is appearing without further positional indication?
推荐答案
我没有直接的功能来获取位置指示.您可以尝试进行转换
I thing there are not direct function to get positional indication.you can try this to convert
print (df)
column
0 01
1 02
2 03
3 04
4 05
5 LS
print (pd.to_numeric(df.column.str, errors='coerce'))
0 1.0
1 2.0
2 3.0
3 4.0
4 5.0
5 NaN
Name: column, dtype: float64
这篇关于ValueError:无法将字符串转换为浮点型-没有位置指示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!