我正在寻找关于如何修复此错误的支持和建议:在python中“无法将字符串ACTL6AS5转换为浮动”。请给我一个例子解决方案,因为我刚开始使用python编程。
运行代码后的错误将很快添加到这里!
#Using the Standard Scaler Model for standardisation of dataset
scaling=StandardScaler()
scaling.fit_transform(Combined_data_df)[['features']]
ValueError Traceback (most recent call last)
<ipython-input-55-bf55a81dd31a> in <module>
----> 1 scaling.fit_transform(Combined_data_df)[['features']]
**ValueError: could not convert string to float: 'ACTL6AS5'**提前谢谢你。
发布于 2021-12-15 03:20:14
你的问题有点不完整..。如果您从用户那里获取一些输入,然后将其转换为string,那么用户输入很可能是不可转换的,就像您试图将'a‘转换成浮点数一样,这会导致这样的错误.
try:
miles = float(input("How many distance you traveled"))
except:
print("Please type in a number!")这称为错误处理,用户输入一些不能转换为浮动的内容,它将告诉用户输入一个正确的值。
https://stackoverflow.com/questions/70357924
复制相似问题