• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
戈瑾
博客园    首页    新随笔    联系   管理    订阅  订阅
问题:object has no attribute"convert_objects"

遇到问题:

今天用python将object数据转化为float数据时,用代码

df.runtime = df.runtime.convert_objects(convert_numeric=True)
df.runtime.describe()

出现如下错误:

 

 

问题解决:

查找资料后发现“.convert_objects(convert_numeric = True)”已弃用,需要改为:b = a.apply(pd.to_numeric, errors=“ignore”)

因此将代码改成

df.runtime = df.runtime.apply(pd.to_numeric, errors="ignore")
df.runtime.describe()

成功:

 

posted on 2021-12-09 14:53  戈瑾  阅读(1416)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3