Generation

generate functionSun, 05 Feb 2023

写一个代码对亚马逊评论情感分析词频统计,里面数据有评论时间,评论内容,评论星级

import pandas as pd import numpy as np import csv from collections import Counter import matplotlib.pyplot as plt df = pd.read_excel('/Users/apple/Desktop/360Downloads/reviews.xlsx') data = df[['review_body','star_rating']] star_rating = data['star_rating'] review_body = data['review_body'] #查看评论星级分布 plt.hist(star_rating,bins=5) #查看评论数量分布 plt.hist(review_body,bins=5) #计算每个星级的评论数量 data.groupby('star_rating',as_index=False)['review_body'].agg({'count':'count'}) #评论的词频统计 word

Questions about programming?Chat with your personal AI assistant