我在Pandas数据帧的一列中进行了文本评论,我想用频率计数计算N个最频繁的单词(在整列中 – 不在单个单元格中).一种方法是通过迭代每一行来使用计数器计数单词.还有更好的选择吗?
代表性数据.
0 a heartening tale of small victories and endu
1 no sophomore slump for director sam mendes w
2 if you are an actor who can relate to the sea
3 it's this memory-as-identity obviation that g
4 boyd's screenplay ( co-written with guardian
解决方法:
Counter(" ".join(df["text"]).split()).most_common(100)
我很确定会给你你想要的东西(在调用most_common之前你可能必须从计数器结果中删除一些非单词)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。