You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OneHotEncoder报错:无法将字符串转为浮点型,求解决方法

OneHotEncoder throws 'cannot convert string to float' error referencing 'VTS' instead of target column 'payment_type'

I'm currently learning Multiple Linear Regression and working through practice exercises. When I try to use OneHotEncoder to convert the payment_type column into categorical variables, I keep hitting this error:

OneHotEncoder Error: cannot convert string to float

I've tried several online troubleshooting solutions, but the error persists. What's really confusing me is that the error mentions failing to convert 'VTS'—not the payment_type column I'm actually trying to process. Up to this point, my code only includes basic data loading steps, no other transformations have been applied.

I've attached a screenshot of my current code and the error message for reference:
Code and error screenshot

Could anyone help me figure out why this error is occurring and how to resolve it?

内容的提问来源于stack exchange,提问作者ra1993

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:17:48