import xlrd import matplotlib.pyplot as plt from wordcloud import WordCloud import jieba #from wordcloud import import pandas as pd class word_cloud(): ''' keylist = ['title','title','title','title','title','title','title','title','title'] ''' def read_excel(self): # 打开excel文件 workbook = xlrd.open_workbook(r'G:\soft\soft_web\soft_app\19分词价格段14000.01-160000.xlsx') # 获取所有的sheet sheet1 = workbook.sheet_by_name('Sheet1') # 获取第二列row_title rows = sheet1.col_values(1) return rows # def word_count(self,data): def word_count(self): ''' 分词和词频统计 :param data: :return: ''' data = self.read_excel() title_s = [] for line in data: title_s.append(jieba.lcut(line.encode('utf-8'))) title_dist = [] for line in title_s: line_dist = [] for word in line: if word not in line_dist:
python生成词云图
最新推荐文章于 2025-06-08 14:56:57 发布