谷歌应用商店APP分析2 --评论词云

Google play store analysis 2

本篇主要分析用户的评论,
环境:python 3.6, anaconda, win 10
库:seaborn, wordcloud

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
#导入数据,APP的评论
comments = pd.read_csv('googleplaystore_user_reviews.csv')
comments.head()
image.png
comments.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 64295 entries, 0 to 64294
Data columns (total 5 columns):
App                       64295 non-null object
Translated_Review         37427 non-null object
Sentiment                 37432 non-null object
Sentiment_Polarity        37432 non-null float64
Sentiment_Subjectivity    37432 non-null float64
dtypes: float64(2), object(3)
memory usage: 2.5+ MB
#丢弃空值
comments.dropna(inplace=True)
#共865个APP,3万7条评论
len(comments['App'].unique())
865
#comments['App'].value_counts()
#好评,中评,差评各多少个
comments['Sentiment'].value_counts()
Positive    23998
Negative     8271
Neutral      5158
Name: Sentiment, dtype: int64
#sns.jointplot(comments['Sentiment_Polarity'],comments['Sentiment_Subjectivity'],kind='kde')
#取出评论具体分析下
review = comments['Translated_Review']

导入wordcloud 做词云看下高频词

final = " ".join(review for review in comments['Translated_Review'])

from wordcloud import WordCloud

word_pic = WordCloud(font_path = r'C:\Windows\Fonts\simkai.ttf',width = 800,height = 400).generate(final)
fig = plt.figure(figsize=(15,9))
plt.imshow(word_pic)
#去掉坐标轴
plt.axis('off')
#保存图片到相应文件夹
plt.savefig(r'7.jpg',dpi=800)
image.png

出现最多的是 game,good,app,time, great,make,work,even等

好像没看出什么有意思的,我们再把好评和差评分开做个词云看看什么结果

final_pos = " ".join(review for review in comments[comments['Sentiment']=='Positive']['Translated_Review'])
#打印一段看下用户的好评
final_pos[0:1000]
'I like eat delicious food. That\'s I\'m cooking food myself, case "10 Best Foods" helps lot, also "Best Before (Shelf Life)" This help eating healthy exercise regular basis Works great especially going grocery store Best idea us Best way Amazing good you. Useful information The amount spelling errors questions validity information shared. Once fixed, 5 stars given. Thank you! Great app!! Add arthritis, eyes, immunity, kidney/liver detox foods please. :) Greatest ever Completely awesome maintain health.... This must ppl there... Love it!!! Good health...... Good health first priority....... Health It\'s important world either life . think? :) Mrs sunita bhati I thankful developers,to make kind app, really good healthy food body Very Useful in diabetes age 30. I need control sugar. thanks One greatest apps. good nice Healthy Really helped HEALTH SHOULD ALWAYS BE TOP PRIORITY. !!. ON MYSG5. An excellent A useful Because I found important. Healthy Eating Very good Simply good Good.!! Thanks a'
word_pic = WordCloud(font_path = r'C:\Windows\Fonts\simkai.ttf',width = 800,height = 400).generate(final_pos)
fig = plt.figure(figsize=(15,9))
plt.imshow(word_pic)
#去掉坐标轴
plt.axis('off')
#保存图片到相应文件夹
plt.savefig(r'pos.jpg',dpi=800)
image.png
final_neg = " ".join(review for review in comments[comments['Sentiment']=='Negative']['Translated_Review'])
#打印一段看下用户的差评
final_neg[:1000]
"No recipe book Unable recipe book. Waste time It needs internet time n ask calls information Faltu plz waste ur time Crap Doesn't work Boring. I thought actually just texts that's it. Too poor old texts.... No recipe book Unable recipe book. Waste time It needs internet time n ask calls information Faltu plz waste ur time Crap Doesn't work Boring. I thought actually just texts that's it. Too poor old texts.... Not bad, price little bit expensive Horrible ID verification There is nothing missing ~ !!! Refund takes long.. 3 days still received money.. crazy I am trying to update every time but I do not stall. It's still difficult to search, and I'm tired of seeing categories by category. The benefits are getting less and less. Icon name is strange after updating It has been slowed down since the last update. It's hard for me to pay for the product ... I'll give up when I'm alive. If a network error occurs, the app should save the state and try again, or try to re-point the next time, but"
word_pic = WordCloud(font_path = r'C:\Windows\Fonts\simkai.ttf',width = 800,height = 400).generate(final_neg)
fig = plt.figure(figsize=(15,9))
plt.imshow(word_pic)
#去掉坐标轴
plt.axis('off')
#保存图片到相应文件夹
plt.savefig(r'neg.jpg',dpi=800)
image.png

对比下两张图,可以看到

跟好评有关的情绪高频词有great,good,love,better,easy等

跟差评有关情绪的词有ad,terrible,bad,worst,suck,useless等

对比category和sentiment

从另一张表导入APP的category

data = pd.read_csv('googleplaystore.csv')
comments.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 37427 entries, 0 to 64230
Data columns (total 5 columns):
App                       37427 non-null object
Translated_Review         37427 non-null object
Sentiment                 37427 non-null object
Sentiment_Polarity        37427 non-null float64
Sentiment_Subjectivity    37427 non-null float64
dtypes: float64(2), object(3)
memory usage: 1.7+ MB
Review=pd.merge(comments,data[['App','Category']],how='left',left_on='App',right_on='App')
Review.drop_duplicates(inplace=True)
Review['Sentiment'].value_counts()
Positive    19871
Negative     6749
Neutral      4461
Name: Sentiment, dtype: int64
len(Review['App'].unique())
865
Review.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 31081 entries, 0 to 74102
Data columns (total 6 columns):
App                       31081 non-null object
Translated_Review         31081 non-null object
Sentiment                 31081 non-null object
Sentiment_Polarity        31081 non-null float64
Sentiment_Subjectivity    31081 non-null float64
Category                  29639 non-null object
dtypes: float64(2), object(4)
memory usage: 1.7+ MB
#分析下不同Catgory的评论情感是否有不同
a= Review['App'].groupby([Review['Category'],Review['Sentiment']]).count()
b =pd.DataFrame(a)
b=b.unstack()
b.head()
image.png
b=b['App']
b.sort('Positive',inplace=True)
C:\Users\renhl1\Anaconda3\lib\site-packages\ipykernel\__main__.py:2: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....)
  from ipykernel import kernelapp as app
fig = plt.figure(figsize=(15,9))
sns.barplot(x=b.index,y=b['Positive'],label='Positive',color='green',alpha=0.8)
sns.barplot(x=b.index,y=b['Neutral'],bottom=b['Positive'],label='Neutral',color='yellow',alpha=0.8)
sns.barplot(x=b.index,y=b['Negative'],bottom=b['Positive']+b['Neutral'],label='Negative',color='red',alpha=0.8)
plt.xticks(rotation=90)
plt.xlabel('category')
plt.ylabel('App qty')
plt.title('App qty by category with different sentiment')
plt.legend()
<matplotlib.legend.Legend at 0x1831167bf98>
image.png

看各category中好评,中评,差评的数量多少,
不过这样不好对比,我们再转化成APP占比进行对比

#计算Ratio
b['Pos_ratio']=b['Positive']/(b['Negative']+b['Neutral']+b['Positive'])
b['Neu_ratio']=b['Neutral']/(b['Negative']+b['Neutral']+b['Positive'])
b['Neg_ratio']=b['Negative']/(b['Negative']+b['Neutral']+b['Positive'])
fig = plt.figure(figsize=(15,9))
sns.barplot(x=b.index,y=b['Pos_ratio'],label='Pos_ratio',color='green',alpha=0.7)
sns.barplot(x=b.index,y=b['Neu_ratio'],bottom=b['Pos_ratio'],label='Neu_ratio',color='yellow',alpha=0.7)
sns.barplot(x=b.index,y=b['Neg_ratio'],bottom=b['Pos_ratio']+b['Neu_ratio'],label='Neg_ratio',color='red',alpha=0.7)
plt.xticks(rotation=90)
plt.xlabel('category')
plt.ylabel('App qty ratio')
plt.title('App qty ratio by category with different sentiment')
plt.legend(loc='upper right',fancybox=True,facecolor='blue',shadow=True).get_frame().set_facecolor('C0')
plt.show()
image.png

可以看到好评较高的category有tools,education,auto and vehicles,commics

以上就是用户评论的初步分析,谢谢!

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,734评论 6 505
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,931评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,133评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,532评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,585评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,462评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,262评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,153评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,587评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,792评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,919评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,635评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,237评论 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,855评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,983评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,048评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,864评论 2 354

推荐阅读更多精彩内容