我想统计数据集中出现频率最高的20个单词,除了标点符号。到目前为止,我尝试的代码是
dataset['token'].value_counts()[:20]
输出:
, 88144
. 49109
dan 37283
di 33701
yang 29353
-LRB- 19843
-RRB- 19736
'' 15906
`` 15232
dengan 15231
pada 15021
dari 14900
tahun 13079
sebagai 9038
ini 8371
untuk 8297
dalam 8266
adalah 7950
menjadi 7414
oleh 5974
但仍然有标点符号。如何做到最高词频不包含标点符号? 谢谢
请尝试以下代码:
假设您对标点符号值不感兴趣。如果同时有标点符号和单词,则会被计算在内
纯Python解决方案
Counter
你必须在计算之前做单词预处理。例如:
祝你好运
相关问题 更多 >
编程相关推荐