在Python3和Pandas中,我有一个从列中制作词云的程序:
import pandas as pd
import numpy as np
from wordcloud import WordCloud
import matplotlib.pyplot as plt
autores_atuais = pd.read_csv("deputados_autores_projetos.csv", sep=',',encoding = 'utf-8', converters={'IdAutor': lambda x: str(x), 'IdDocumento': lambda x: str(x), 'CodOriginalidade': lambda x: str(x), 'IdNatureza': lambda x: str(x), 'NroLegislativo': lambda x: str(x)})
autores_atuais.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 6632 entries, 74057 to 84859
Data columns (total 10 columns):
IdAutor 6632 non-null object
IdDocumento 6632 non-null object
NomeAutor 6632 non-null object
AnoLegislativo 6632 non-null object
CodOriginalidade 5295 non-null object
DtEntradaSistema 6632 non-null object
DtPublicacao 6632 non-null object
Ementa 6632 non-null object
IdNatureza 6632 non-null object
NroLegislativo 6632 non-null object
dtypes: object(10)
memory usage: 569.9+ KB
wordcloud = WordCloud().generate(' '.join(autores_atuais['Ementa']))
plt.imshow(wordcloud)
plt.axis("off")
plt.show()
请问,我如何在云中忽略某些单词?例如,小单词(“的”,“奥”)和特定单词(“Estado”)
nltk
包中导入停用词列表。他们提供了许多语言的停用词列表。如果你只需要停用词,那么nltk
包可能有些过于复杂,但如果你会在其他方面使用它,那么它可能会很有用。 - Silenced Temporarily