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()
comments.info()
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)
出现最多的是 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)
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)
对比下两张图,可以看到
跟好评有关的情绪高频词有great,good,love,better,easy等
跟差评有关情绪的词有ad,terrible,bad,worst,suck,useless等
对比category和sentiment
从另一张表导入APP的category
data = pd.read_csv('googleplaystore.csv')
comments.info()
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()
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()
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()
看各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()
可以看到好评较高的category有tools,education,auto and vehicles,commics
以上就是用户评论的初步分析,谢谢!