问题:object has no attribute"convert_objects"

 

遇到问题:

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

1
2
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”)

因此将代码改成

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

成功:

posted on 2023-05-14 22:57  杨申龙  阅读(12)  评论(0)    收藏  举报