工作中使用pandas遇到这个情况, 'Series' object has no attribute 'len' 及TypeError: object of type 'float' has no len() , difflib
先暂时记录下当时的处理方法,仅贴出关键代码:
# 数据处理 - 短句过滤: 即至少4个字的评论才会被保留
df["content"] = df["content"].astype(str)
df = df[df["content"].str.len() <= 4]
print(df)