Google play store analysis 2
本篇主要分析用戶的評(píng)論,
環(huán)境:python 3.6, anaconda, win 10
庫(kù):seaborn, wordcloud
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
#導(dǎo)入數(shù)據(jù),APP的評(píng)論
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個(gè)APP,3萬(wàn)7條評(píng)論
len(comments['App'].unique())
865
#comments['App'].value_counts()
#好評(píng),中評(píng),差評(píng)各多少個(gè)
comments['Sentiment'].value_counts()
Positive 23998
Negative 8271
Neutral 5158
Name: Sentiment, dtype: int64
#sns.jointplot(comments['Sentiment_Polarity'],comments['Sentiment_Subjectivity'],kind='kde')
#取出評(píng)論具體分析下
review = comments['Translated_Review']
導(dǎo)入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)
#去掉坐標(biāo)軸
plt.axis('off')
#保存圖片到相應(yīng)文件夾
plt.savefig(r'7.jpg',dpi=800)

image.png
出現(xiàn)最多的是 game,good,app,time, great,make,work,even等
好像沒(méi)看出什么有意思的,我們?cè)侔押迷u(píng)和差評(píng)分開做個(gè)詞云看看什么結(jié)果
final_pos = " ".join(review for review in comments[comments['Sentiment']=='Positive']['Translated_Review'])
#打印一段看下用戶的好評(píng)
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)
#去掉坐標(biāo)軸
plt.axis('off')
#保存圖片到相應(yīng)文件夾
plt.savefig(r'pos.jpg',dpi=800)

image.png
final_neg = " ".join(review for review in comments[comments['Sentiment']=='Negative']['Translated_Review'])
#打印一段看下用戶的差評(píng)
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)
#去掉坐標(biāo)軸
plt.axis('off')
#保存圖片到相應(yīng)文件夾
plt.savefig(r'neg.jpg',dpi=800)

image.png
對(duì)比下兩張圖,可以看到
跟好評(píng)有關(guān)的情緒高頻詞有g(shù)reat,good,love,better,easy等
跟差評(píng)有關(guān)情緒的詞有ad,terrible,bad,worst,suck,useless等
對(duì)比category和sentiment
從另一張表導(dǎo)入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的評(píng)論情感是否有不同
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中好評(píng),中評(píng),差評(píng)的數(shù)量多少,
不過(guò)這樣不好對(duì)比,我們?cè)俎D(zhuǎn)化成APP占比進(jìn)行對(duì)比
#計(jì)算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
可以看到好評(píng)較高的category有tools,education,auto and vehicles,commics
以上就是用戶評(píng)論的初步分析,謝謝!