1. 首页
  2. Pandas

pandas词频统计

pandas词频统计

keyword_Obj={
    "新能源":"新能源",
    "新能源汽车":"新能源汽车",
    "汽车":"汽车"
}
for key,value in keyword_Obj.items():
    print(key,'----',value)
    df[key]=df['content'].str.findall(r'{pattern}'.format(pattern=value)).str.len()

 ### 参考

[python – How to do word count on pandas dataframe – Stack Overflow](https://stackoverflow.com/questions/54397096/how-to-do-word-count-on-pandas-dataframe)

发表评论

登录后才能评论

评论列表(1条)