AttributeError:“ float”对象在熊猫中没有属性“ split”

时间:2019-02-25 22:05:04

标签: python pandas python-2.7 data-science

我想计算每行标签的数量,但是在遍历每一行时,即使我的列数据类型是object,我也遇到了属性错误。参见下面的代码。

Tag_data.dtypes
Id            int64

标题对象 身体对象 标签对象 dup_count int64 dtype:对象

actual code 
Tag_data["tag_counts"]=Tag_data["Tags"].apply(lambda  text:len(text.split(" ")))
Tag_data.head()

AttributeError:“ float”对象没有属性“ split”

1 个答案:

答案 0 :(得分:0)

似乎“标签”列的数据类型为浮点型。 在应用拆分功能之前,尝试将其更改为字符串:Tag_data ['Tags']。apply(str)

相关问题