-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaystore.py
2178 lines (1793 loc) · 87.2 KB
/
playstore.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import pandas as pd
import numpy as np
from tkinter import *
from tkinter import messagebox
import re,pymysql
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
import PIL
from PIL import ImageTk, Image
import path
import os
import seaborn as sns
import io
import math
from collections import OrderedDict
from datetime import datetime
from datetime import time
from datetime import date
import time
from tkinter.ttk import *
from tkcalendar import Calendar,DateEntry
import tkinter as tk
from tkinter import font as tkfont
import matplotlib.style as style
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from string import ascii_letters
from tkinter.filedialog import asksaveasfile
from matplotlib.backends.backend_pdf import PdfPages
from sklearn import preprocessing
from sklearn.metrics import accuracy_score
from sklearn.tree import DecisionTreeClassifier
from datetime import datetime
from textblob import TextBlob as tb
import openpyxl
from openpyxl import *
import xlrd
import xlsxwriter
from xlutils.copy import copy
pd.options.mode.chained_assignment=None
def adjustWindow(window,screen):
w = screen.winfo_screenwidth() # width of the screen
h = screen.winfo_screenheight() # height of the screen
window.geometry('%dx%d' % (w, h)) # set the dimensions of the screen and where it is placed
window.resizable(True, True) # disabling the resize option for the window
window.configure(background='white') # making the background white of the window
##=============15================================
def q15():
global positive,negative,neutral,total_sentiment,positive_percent,neutral_percent,negative_percent
df = pd.read_excel('googleplaystore_user_reviews.xlsx')
df=df.dropna()
df=df[df['App']=='10 Best Foods for You']
df1=dict(tuple(df.groupby(['Sentiment'])))
negative=len(df1['Negative'])
neutral=len(df1['Neutral'])
positive=len(df1['Positive'])
total_sentiment=positive+negative+neutral
positive_percent=(positive/total_sentiment)*100
positive_percent=round(positive_percent,2)
neutral_percent=(neutral/total_sentiment)*100
neutral_percent=round(neutral_percent,2)
negative_percent=(negative/total_sentiment)*100
negative_percent=round(negative_percent,2)
def pie():
plt.figure(figsize=(8,4))
figureObject,axesObject=plt.subplots()
plt.pie(
[positive,neutral,negative],
labels=['Positive','Neutral','Negative'],
colors=['#33cc33','#99ff66','#ccff99'],
startangle=90,
autopct='%1.2f'
)
axesObject.axis('equal')
plt.savefig('testplot.png')
img=Image.open('testplot.png').save('testplot.png','PNG')
plt.close()
def main15():
global screen15,p
screen15=tk.Toplevel(screenr2)
p=tk.StringVar(master=screen15)
q15()
pie()
screen15.title("10 Best foods for you")
adjustWindow(screen15,screen15)
screen15.configure(background='#ffff99')
path = "testplot.png"
img=Image.open(path)
img=img.resize((500,400),Image.ANTIALIAS)
img = ImageTk.PhotoImage(img, master=screen15)
panel = tk.Label(screen15, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
if (positive_percent>negative_percent) and (positive_percent>neutral_percent):
p.set(value=positive_percent)
a1=tk.Label(screen15,text='The App "10 Best Foods for You" has %s positive response.\nLaunching a similar App is advisable since users like such apps.'%(p.get()), width='10', height="8", font=("Calibri", 20,'bold'), fg='black', bg='#ccff66')
a1.pack(fill=X)
else:
a2=tk.Label(screen15,text='The App "10 Best Foods for You" has %s positive response.\nLaunching a similar App is inadvisable since users do not like such apps.'%(p.get()), width='10', height="8", font=("Calibri", 20,'bold'), fg='black', bg='#ccff66')
a2.pack(fill=X)
p.set(value=positive_percent)
a3=tk.Label(screen15,text='%s'%(p.get()))
b1=tk.Button(screen15, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screenr2.destroy)
b1.place(x=0,y=0)
b2=tk.Button(screen15,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen15.destroy)
b2.place(x=110,y=0)
screen15.mainloop()
##===========================17===============================
def bar():
df = pd.read_excel('googleplaystore_App_data.xlsx')
df=df.dropna()
df['Size']=df['Size'].str.rstrip('M')
df['Size']=pd.to_numeric(df['Size'],errors='coerce')
df.groupby('Installs')["Size"].mean().sort_values(ascending=True).plot(kind='bar',figsize=(10,10),color='#ccccff')
plt.ylabel('Avg.Size(in MB)')
plt.xlabel('Downloads')
if os.path.isfile('abc.png'):
os.remove('abc.png')
plt.savefig('abc.png')
Image.open('abc.png').save('abc.png','PNG')
plt.close()
def main17():
global screen17
screen17=tk.Toplevel(screend1)
screen17.title("Installs vs App Size")
adjustWindow(screen17,screen17)
bar()
a1=tk.Label(screen17,text='App Downloads and App Size', width='10', height="2", font=("Calibri", 15,'bold'), fg='black', bg='#66ff33')
a1.pack(fill=X)
path = "abc.png"
img=Image.open(path)
img=img.resize((700,700),Image.ANTIALIAS)
img = ImageTk.PhotoImage(img, master=screen17)
panel = tk.Label(screen17, image = img)
panel.place(x=750,y=55)
b1=tk.Button(screen17, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screend1.destroy)
b1.place(x=0,y=0)
b2=tk.Button(screen17,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen17.destroy)
b2.place(x=110,y=0)
a2=tk.Label(screen17, text="Apps which have big size,have more number of installs\n as App having more size are much better and dynamic. ", bg='#ccff66', height='2',font=("Calibri", 12, 'bold'))
a2.place(x=100, y=200)
screen17.mainloop()
#####============================14=================================
def q14():
global screen14_1
if (app.get()=='----Select app----' or app.get()==''or review.get()=='--Select Type--'):
messagebox.showerror('Select Proper Fields')
else:
screen14_1=tk.Toplevel(screen14)
screen14_1.title('Reviews')
adjustWindow(screen14_1,screen14_1)
a1=tk.Label(screen14_1, text="%s\n%s Reviews"%(app.get(),review.get()), width='32', height="2",font=("Calibri", 22, 'bold'), fg='white', bg='#66ff33')
a1.pack(side='top',anchor='n',fill = X, expand = "yes")
t=tk.Text(screen14_1)
reviewlist=[]
r=tk.StringVar(master=screen14)
df = pd.read_excel('googleplaystore_user_reviews.xlsx')
df=df.dropna()
for i in range(len(df.index)):
if df.iloc[i].App == app.get():
if df.iloc[i].Sentiment == review.get():
reviewlist.append(df.iloc[i].Translated_Review)
t=tk.Text(screen14_1,bg='yellow',bd='4',pady='10',height=screen14_1.winfo_screenheight(),relief='groove',wrap='word',font=("Open Sans",10, 'bold'))
for i in range(len(reviewlist)):
t.insert(END, str(i+1)+"."+reviewlist[i]+'\n\n')
t.config(state='disabled')
t.pack(pady='10')
b1=tk.Button(screen14_1, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screenr2.destroy)
b1.place(x=0,y=0)
b2=tk.Button(screen14_1,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen14_1.destroy)
b2.place(x=110,y=0)
screen14_1.mainloop()
def main14():
global app,screen14,review
screen14=tk.Toplevel(screenr2)
app =tk.StringVar(master=screen14)
review=tk.StringVar(master=screen14)
screen14.title("REVIEWS")
df = pd.read_excel('googleplaystore_user_reviews.xlsx')
df=df.dropna()
adjustWindow(screen14,screen14)
a1=tk.Label(screen14, text="User Reviews ", width='32', height="2",font=("Calibri", 22, 'bold'), fg='white', bg='#66ff33')
a1.pack(side='top',anchor='n',fill = X, expand = "yes") #place(x=(screen14.winfo_screenwidth())/2, y=0)
a2=tk.Label(screen14, text="App", bg='#ffff00', width='20', height='2',font=("Calibri", 15, 'bold'))
a2.place(x=400, y=120)
list1=df['App'].unique().tolist()
c1=ttk.Combobox(screen14 , width=55, values = list1 ,textvariable = app,)
c1.place(x=650,y=130)
app.set('----Select app----')
a3 = tk.Label(screen14, text="Review", bg='#ffff00', width='20', height='2',font=("Calibri", 15, 'bold'))
a3.place(x=400, y=200)
list2=['Positive','Negative','Neutral']
droplist2=tk.OptionMenu(screen14,review, *list2)
droplist2.config(width=50)
review.set('--Select Type--')
droplist2.place(x=650,y=215)
b1=tk.Button(screen14, text='Submit', width=15 ,height=2,font=("Open Sans", 13, 'bold'), bg='#ff0000',fg='white',command=q14)
b1.place(x=650, y=490)
b2=tk.Button(screen14, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screenr2.destroy)
b2.place(x=0,y=0)
b3=tk.Button(screen14,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen14.destroy)
b3.place(x=110,y=0)
screen14.mainloop()
#####====================9=======================
def q9():
global t1
df = pd.read_excel('googleplaystore_App_data.xlsx')
df=df.dropna()
df['Installs']=df['Installs'].str.rstrip('+')
df['Installs']=df['Installs'].str.replace(',','').astype(float)
t1=[]
for i in range(len(df.index)):
if (df.iloc[i].Installs >= 100000) and (df.iloc[i].Rating >=4.1):
t1.append(df.iloc[i].App)
def plot9():
df = pd.read_excel('googleplaystore_App_data.xlsx')
df.dropna()
df=df.set_index("App")
df=df.drop('Life Made WI-Fi Touchscreen Photo Frame',axis=0)
data={'Installs':df['Installs'],'Rating':df['Rating']}
df1=pd.DataFrame(data)
df1['Installs']=df1['Installs'].str.rstrip('+')
df1['Installs']=df1['Installs'].str.replace(',','').astype(float)
df1=df1.sort_values(by='Installs')
ax=sns.barplot(x=df1['Installs'], y=df1['Rating'],palette='husl')
plt.xticks(rotation=90)
ax.set(xlabel='Installs',ylabel='Rating')
plt.tight_layout()
plt.savefig('dwnldVsrating.png')
img=Image.open('dwnldVsrating.png').save('dwnldVsrating.png','PNG')
plt.close()
def main9():
global screen9
screen9=tk.Toplevel(screenr1)
adjustWindow(screen9,screen9)
screen9.title('Downloads and Rating')
q9()
plot9()
path = "dwnldVsrating.png"
img=Image.open(path)
img=img.resize((500,350),Image.ANTIALIAS)
img = ImageTk.PhotoImage(img, master=screen9)
panel = tk.Label(screen9, image = img)
panel.place(x=50,y=200)
a1=tk.Label(screen9, text="Apps Having downloads over 1,00,000 and Rating 4.1 and above\n", font=("Open Sans", 12, 'bold'), fg='black',bg='#66ff33')
a1.place(x=800,y=0)
a2=tk.Label(screen9,text='Apps having more installs,have comapritively less overall rating\nAs they are diluted by low ratings ',font=("Open Sans", 12, 'bold'), fg='black',bg='#66ff33')
a2.place(x=60,y=50)
t=tk.Text(screen9,bg='yellow',bd='4',pady='10',height=screen9.winfo_screenheight(),font=("Open Sans",10, 'bold'))
for i in range(len(t1)):
t.insert(END, str(i+1)+"."+t1[i]+'\n\n')
t.config(state='disabled')
t.place(x=750,y=50)
b1=tk.Button(screen9, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screenr1.destroy)
b1.place(x=0,y=0)
b2=tk.Button(screen9,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen9.destroy)
b2.place(x=110,y=0)
screen9.mainloop()
###======================10==================================
def month(x):
if x[0:3]=='Jan':
return 1
elif x[0:3]=='Feb':
return 2
elif x[0:3]=='Mar':
return 3
elif x[0:3]=='Apr':
return 4
elif x[0:3]=='May':
return 5
elif x[0:3]=='Jun':
return 6
elif x[0:3]=='Jul':
return 7
elif x[0:3]=='Aug':
return 8
elif x[0:3]=='Sep':
return 9
elif x[0:3]=='Oct':
return 10
elif x[0:3]=='Nov':
return 11
elif x[0:3]=='Dec':
return 12
def dates_str_to_int():
global sample
sample=sample.set_index("App")
sample=sample.drop('Life Made WI-Fi Touchscreen Photo Frame',axis=0)
sample=sample.dropna()
sample['Last Updated'] = sample['Last Updated'].dt.strftime('%d-%b-%y')
dates=sample['Last Updated']
year=[]
counter=0
for i in dates:
year.append([int(i[:-7]),month(i[-6:-3]),int(i[-2:])])
counter=counter+1
return year
def install():
Installs=[]
global sample
sample['Installs']=sample['Installs'].str.rstrip('+')
sample['Installs']=sample['Installs'].str.replace(',','').astype(float)
sample=sample.dropna()
for i in sample['Installs']:
Installs.append(int(i))
return Installs
def qn10():
year=dates_str_to_int()
installs=install()
category=list(OrderedDict.fromkeys(sample['Category']))
temp=[]
counter=0
for i in category:
temp.append([0,0,0,0,0,0,0,0,0,0,0,0])
for i in sample['Category']:
jcounter=0
for j in category:
if i==j:
if year[counter][1]==1:
temp[jcounter][0]=temp[jcounter][0]+installs[counter]
elif year[counter][1]==2:
temp[jcounter][1]=temp[jcounter][1]+installs[counter]
elif year[counter][1]==3:
temp[jcounter][2]=temp[jcounter][2]+installs[counter]
elif year[counter][1]==4:
temp[jcounter][3]=temp[jcounter][3]+installs[counter]
elif year[counter][1]==5:
temp[jcounter][4]=temp[jcounter][4]+installs[counter]
elif year[counter][1]==6:
temp[jcounter][5]=temp[jcounter][5]+installs[counter]
elif year[counter][1]==7:
temp[jcounter][6]=temp[jcounter][6]+installs[counter]
elif year[counter][1]==8:
temp[jcounter][7]=temp[jcounter][7]+installs[counter]
elif year[counter][1]==9:
temp[jcounter][8]=temp[jcounter][8]+installs[counter]
elif year[counter][1]==10:
temp[jcounter][9]=temp[jcounter][9]+installs[counter]
elif year[counter][1]==11:
temp[jcounter][10]=temp[jcounter][10]+installs[counter]
elif year[counter][1]==12:
temp[jcounter][11]=temp[jcounter][11]+installs[counter]
jcounter=jcounter+1
counter=counter+1
return temp
def q10_2():
global sum2,sum1,f1
df=pd.read_excel('googleplaystore_App_data.xlsx')
df=df.set_index("App")
df=df.drop('Life Made WI-Fi Touchscreen Photo Frame',axis=0)
df=df.dropna()
df['Installs']=df['Installs'].str.rstrip('+')
df['Installs']=df['Installs'].str.replace(',','').astype(float)
d1= (df[(df['Content Rating'] == 'Teen')].Installs).to_list()
e1= (df[(df['Content Rating'] == 'Mature 17+')].Installs).to_list()
sum1=sum(d1)
sum2=sum(e1)
f1=sum1/sum2
f1=str(round(f1,2))
sum1=str(sum1)
sum2=str(sum2)
def plot10() :
global sample,cat,mon
sample=pd.read_excel('googleplaystore_App_data.xlsx')#reading data for the data set
sample=sample.replace(np.NaN,0)
sample.drop(index=[10474],inplace=True)
cate_month = qn10()
dict_month = {1:'Jan',2:'Feb',3:'March',4:'April',5:'May',6:'June',7:'July',8:'Aug',9:'Sept',10:'Oct',11:'Nov',12:'Dec'}
categories = []
months = []
maxinstalls = []
cat = sample['Category'].unique()
for index in range(len(cat)):
categories.append(cat[index])
maxinstalls.append(max(cate_month[index]))
m = (cate_month[index].index(max(cate_month[index]))+1)
months.append(dict_month[m])
category_dict=dict(zip(categories,months))
for key,value in category_dict.items():
if key=='GAME':
cat=key
mon=value
plt.figure(figsize=(15,15))
plt.plot(categories,maxinstalls)
plt.title('CATEGORY vs INSTALLS',fontsize=15)
plt.xticks(rotation=90)
plt.xlabel('CATEGORY', fontsize = 15)
plt.ylabel('INSTALLS', fontsize = 15)
plt.savefig('q10.png')
Image.open('q10.png').save('q10.png','PNG')
plt.close()
# plt.show()
def main10():
global screen10
screen10=tk.Toplevel(screenc1)
adjustWindow(screen10,screen10)
screen10.title('Category Installs')
l1=tk.Label(screen10,text='Category Month', width='10', height="3", font=("Calibri", 15,'bold'), fg='black', bg='#66ff33')
l1.pack(fill=X)
plot10()
q10_2()
path='q10.png'
img=Image.open(path)
img=img.resize((732,588),Image.ANTIALIAS)
img = ImageTk.PhotoImage(img, master=screen10)
panel = tk.Label(screen10, image = img)
panel.place(x=800,y=100)
txt2='The month of '+mon+' has seen the maximum downloads for '+cat+' category.'
a1=tk.Label(screen10, text=txt2 , font=('calibri',15,'bold'),fg='black',bg='#ffff00')
a1.place(x=20,y=120)
txt4='Number of Teen downloads: '+sum1+'\n\nNumber of Mature 17+ downloads: '+sum2+'\n\nRatio of downloads for the app that qualifies as teen versus mature17+ : '+f1
a2=tk.Label(screen10, text=txt4 , font=('calibri',15,'bold'),fg='black',bg='#ffff00')
a2.place(x=20,y=120)
b1=tk.Button(screen10, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screenc1.destroy)
b1.place(x=0,y=0)
b2=tk.Button(screen10,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen10.destroy)
b2.place(x=110,y=0)
screen10.mainloop()
###==============================11==========================
def q11():
global quarter_ans,yr,qr
df = pd.read_excel('googleplaystore_App_data.xlsx')
df=df.set_index("App")
df=df.drop('Life Made WI-Fi Touchscreen Photo Frame',axis=0)
df=df.dropna()
df=df.reset_index()
df['Installs']=df['Installs'].str.rstrip('+')
df['Installs']=df['Installs'].str.replace(',','').astype(int)
data={'App':df['App'],'Installs':df['Installs'],'Last':df['Last Updated']}
df1=pd.DataFrame(data)
df1['Last']=df['Last Updated'].dt.date
df1=df1.sort_values(by='Last')
df1['Last']=df['Last Updated'].dt.to_period('Q')
c=df1['Last'].to_list()
uniqueQ=[]
q={}
for i in c:
if i not in uniqueQ:
uniqueQ.append(i)
for i in uniqueQ:
df_a=(df1[(df1.Last==i)].Installs).to_list()
q.update({i:sum(df_a)})
v=list(q.values())
k=list(q.keys())
quarter_ans= k[v.index(max(v))]
c=str(quarter_ans)
qr=c[4:]
yr=c[:4]
def main11():
global screen11
screen11=tk.Toplevel(screend1)
screen11.title("Quarter")
adjustWindow(screen11,screen11)
q11()
a1=tk.Label(screen11,text='Quarter and Installs', width='10', height="2", font=("Calibri", 15,'bold'), fg='black', bg='#66ff33')
a1.pack(fill=X)
txt3=qr+' of year '+yr+' has generated the highest number of install for each app used in the study. '
a2=tk.Label(screen11,text=txt3, width='50', height="50", font=("Calibri", 20,'bold'), fg='black', bg='#174873')
a2.pack(pady=100,fill=X)
b1=tk.Button(screen11, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screend1.destroy)
b1.place(x=0,y=0)
b2=tk.Button(screen11,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen11.destroy)
b2.place(x=110,y=0)
screen11.mainloop()
###============================12=========================
def q12():
global p_ans,n_ans,same_ratio
df=pd.read_excel('googleplaystore_user_reviews.xlsx')
df=df.dropna()
l1=df['App'].unique().tolist()
positive_dict={}
negative_dict={}
same_ratio=[]
for i in l1:
x=i
df1 = df[(df.App ==x) ]
df1 =df1[(df1.Sentiment=='Positive')]
df2 = df[(df.App ==x) ]
df2 =df2[(df2.Sentiment=='Negative')]
a=len(df1.index)
b=len(df2.index)
try:
c=a/b
except ZeroDivisionError:
c=0
positive_dict.update({i:len(df1.index)})
negative_dict.update({i:len(df2.index)})
if c==1:
same_ratio.append(i)
v=list(positive_dict.values())
k=list(positive_dict.keys())
p_ans= k[v.index(max(v))]
x=list(negative_dict.values())
y=list(negative_dict.keys())
n_ans= y[x.index(max(x))]
def main12():
global screen12
screen12=tk.Toplevel(screens1)
screen12.title("Category Downloads")
adjustWindow(screen12,screen12)
q12()
a1=tk.Label(screen12,text='Positive and Negative Sentiments', width='10', height="2", font=("Calibri", 15,'bold'), fg='black', bg='#66ff33')
a1.pack(fill=X)
s1=' App which has generated the most Positive Sentiments : '+p_ans+'\n\n\nApp which has generated the most Negative Sentiments : '+n_ans+'\n\n\n'
l2=tk.Label(screen12,text=s1,width='63',height='20' ,font=("Helvetica",13, 'bold', 'italic'), fg='black', bg='#fa3e3e')
l2.place(x=80,y=150)
a2=tk.Label(screen12,text='Apps having same ratio for Positive and Negative Sentiments ', height="2",font=("Calibri", 15,'bold'), fg='black', bg='#5225d9')
a2.place(x=800,y=80)
t=tk.Text(screen12,bg='yellow',bd='4',pady='10',padx='20',height=screen12.winfo_screenheight(),font=("Open Sans",10, 'bold'))
for i in range(len(same_ratio)):
t.insert(END, str(i+1)+"."+same_ratio[i]+'\n\n')
t.config(state='normal')
t.place(x=750,y=150)
b1=tk.Button(screen12, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screens1.destroy)
b1.place(x=0,y=0)
b2=tk.Button(screen12,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen12.destroy)
b2.place(x=110,y=0)
screen12.mainloop()
#####=============================13============================
def plot13():
df = pd.read_excel('D:\PyInt\googleplaystore_user_reviews.xlsx')
sns.scatterplot(df['Sentiment_Polarity'],df['Sentiment_Subjectivity'] ,hue=df['Sentiment'], edgecolor='white',palette="husl")
plt.xlabel('Sentiment Polarity', fontsize=10)
plt.ylabel('Sentiment Subjectivity', fontsize=10)
plt.title("Sentiment Analysis", fontsize=10)
plt.savefig('q13.png')
Image.open('q13.png').save('q13.png','PNG')
plt.close()
def main13():
global screen13
screen13=tk.Toplevel(screens1)
adjustWindow(screen13,screen13)
screen13.title('Sentiment Analysis')
l1=tk.Label(screen13,text='Sentiment Polarity and Sentiment Subjectivity', width='10', height="3", font=("Calibri", 15,'bold'), fg='black', bg='#66ff33')
l1.pack(fill=X)
plot13()
path='q13.png'
img=Image.open(path)
img = ImageTk.PhotoImage(img, master=screen13)
panel = tk.Label(screen13, image = img)
panel.pack()
b1=tk.Button(screen13, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screens1.destroy)
b1.place(x=0,y=0)
b2=tk.Button(screen13,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen13.destroy)
b2.place(x=110,y=0)
screen13.mainloop()
#####==========================16============================
def plot16():
df = pd.read_excel('googleplaystore_App_data.xlsx')
df=df.dropna()
data={'Installs':df['Installs'],'Last Updated':df['Last Updated']}
df1=pd.DataFrame(data)
df1['Last Updated']=df['Last Updated'].dt.month
df1['Installs']=df1['Installs'].str.rstrip('+')
df1['Installs']=df1['Installs'].str.replace(',','').astype(float)
df1=df1.sort_values(by='Last Updated')
dict_months={1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun',7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'}
sns.set_style("whitegrid")
sns.set_context("paper")
g=sns.barplot(df1['Last Updated'],df1['Installs'],palette='husl',edgecolor='white')
g.set(xticklabels=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'])
g.set(xlabel='Months',ylabel='Downloads')
plt.savefig('dwnldVsmonth.png')
img=Image.open('dwnldVsmonth.png').save('dwnldVsmonth.png','PNG')
plt.close()
def main16():
global screen16
screen16=tk.Toplevel(screend1)
adjustWindow(screen16,screen16)
screen16.title('Downloads Vs Months')
plot16()
screen16.config(background='#ffff99')
path = "dwnldVsmonth.png"
img=Image.open(path)
img=img.resize((500,350),Image.ANTIALIAS)
img = ImageTk.PhotoImage(img, master=screen16)
panel = tk.Label(screen16, image = img)
a1=tk.Label(screen16,text='July and August is the best indicator to the average downloads \nthat an App will generate over the entire year.', width='50', height="2", font=("Calibri", 15,'bold'), fg='black', bg='#66ff33')
a1.pack(fill=X)
panel.pack(padx=20,pady=50)
b1=tk.Button(screen16, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screend1.destroy)
b1.place(x=0,y=0)
b2=tk.Button(screen16,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen16.destroy)
b2.place(x=110,y=0)
screen16.mainloop()
#####==========================8==========================
def plot1():
global df_apps
df_apps=pd.DataFrame()
df_apps = pd.read_excel('googleplaystore_App_data.xlsx')
df_apps=df_apps.dropna()
df_apps = df_apps[(df_apps['Category'] == "SPORTS") |
(df_apps['Category'] == "ENTERTAINMENT") | (df_apps['Category'] == "SOCIAL")
| (df_apps['Category'] == "NEWS_AND_MAGAZINES") | (df_apps['Category'] ==
"EVENTS") | (df_apps['Category'] == "TRAVEL_AND_LOCAL")|
(df_apps['Category'] == "GAME")]
df1=df_apps[(df_apps['Category'] == "GAME")]
df1['Installs']=df1['Installs'].str.rstrip('+')
df1['Installs']=df1['Installs'].str.replace(',','').astype(float)
df1['Last Updated']=df_apps['Last Updated'].dt.date
df1['Last Updated']=df_apps['Last Updated'].dt.year
a=df1.groupby('Last Updated')["Installs"].mean()
a.plot(kind='line',figsize=(5,5),color='blue')
plt.xlabel('Year')
plt.ylabel('Installs(in 10millions)')
plt.title('GAME')
plt.savefig('game.png')
img=Image.open('game.png').save('game.png')
plt.close()
def plot2():
df2=df_apps[(df_apps['Category'] == "ENTERTAINMENT")]
df2['Installs']=df2['Installs'].str.rstrip('+')
df2['Installs']=df2['Installs'].str.replace(',','').astype(float)
df2['Last Updated']=df_apps['Last Updated'].dt.date
df2['Last Updated']=df_apps['Last Updated'].dt.year
b=df2.groupby('Last Updated')["Installs"].mean()
b.plot(kind='bar',figsize=(5,5),color='red')
plt.xlabel('Year')
plt.ylabel('Installs(in 10millions)')
plt.title('ENTERTAINMENT')
plt.savefig('entertainment.png')
img=Image.open('entertainment.png').save('entertainment.png')
plt.close()
def plot3():
df2=df_apps[(df_apps['Category'] == "EVENTS")]
df2['Installs']=df2['Installs'].str.rstrip('+')
df2['Installs']=df2['Installs'].str.replace(',','').astype(float)
df2['Last Updated']=df_apps['Last Updated'].dt.date
df2['Last Updated']=df_apps['Last Updated'].dt.year
c=df2.groupby('Last Updated')["Installs"].mean()
c.plot(kind='bar',figsize=(5,5),color='red')
plt.xlabel('Year')
plt.ylabel('Install')
plt.title('EVENTS')
plt.savefig('events.png')
img=Image.open('events.png').save('events.png')
plt.close()
def text_parameters(i):
df_apps = pd.read_excel('googleplaystore_App_data.xlsx')
df_apps=df_apps.dropna()
df_apps['Installs']=df_apps['Installs'].str.rstrip('+')
df_apps['Installs']=df_apps['Installs'].str.replace(',','').astype(float)
text=[]
cor1=[]
cor2=[]
if i==1:
df_apps = df_apps[(df_apps['Category'] == "SPORTS") |
(df_apps['Category'] == "ENTERTAINMENT") | (df_apps['Category'] == "SOCIAL")
| (df_apps['Category'] == "NEWS_AND_MAGAZINES") | (df_apps['Category'] ==
"EVENTS") | (df_apps['Category'] == "TRAVEL_AND_LOCAL")|
(df_apps['Category'] == "GAME")]
else:
pass
df_apps.dtypes
df_apps["Type"] = (df_apps["Type"] == "Paid").astype(int)
corr = df_apps.apply(lambda x: x.factorize()[0]).corr()
for i in df_apps.columns:
for j in df_apps.columns:
if corr[i][j]<(-0.25):
cor1.append(i)
cor2.append(j)
cor1=np.array(cor1)
strong_cor=list(np.unique(cor1))
df_apps['Size'].replace('Varies with device', np.nan, inplace=True)
df_apps=df_apps.dropna(how='any',axis=0)
df_apps['Size']=df_apps['Size'].str.rstrip('M,k')
df_apps['Size']=df_apps['Size'].astype(float)
popAppsCopy = df_apps.copy()
label_encoder = preprocessing.LabelEncoder()
df_app=[]
popAppsCopy['Category']=label_encoder.fit_transform(popAppsCopy['Category'])
popAppsCopy['Category']=label_encoder.inverse_transform(popAppsCopy['Category'])
df_app=list(df_apps['Category'])
popAppsCopy['Category']=label_encoder.fit_transform(popAppsCopy['Category'])
popAppsCopy['Content Rating']=label_encoder.fit_transform(popAppsCopy['Content Rating'])
popAppsCopy['Genres']=label_encoder.fit_transform(popAppsCopy['Genres'])
popAppsCopy.dtypes
popAppsCopy = popAppsCopy.drop(["App","Last Updated","Current Ver","Android Ver"],axis=1)
countPop = popAppsCopy[popAppsCopy["Installs"] > 100000].count()
popular_apps="{} Apps are Popular!".format(countPop[0])
popAppsCopy["Installs"] = (popAppsCopy["Installs"] > 100000)*1
testPop1 = popAppsCopy[popAppsCopy["Installs"] ==1].sample(1010,random_state=0)
popAppsCopy = popAppsCopy.drop(testPop1.index)
testPop0 = popAppsCopy[popAppsCopy["Installs"] ==0].sample(0,random_state=0)
popAppsCopy = popAppsCopy.drop(testPop0.index)
testDf = testPop1.append(testPop0)
trainDf = popAppsCopy
testDf = testDf.sample(frac=1,random_state=0).reset_index(drop=True)
trainDf = trainDf.sample(frac=1,random_state=0).reset_index(drop=True)
y_train = trainDf.pop("Installs")
X_train = trainDf.copy()
y_test = testDf.pop("Installs")
X_test = testDf.copy()
popularity_classifier = DecisionTreeClassifier(max_leaf_nodes=29,random_state=0)
popularity_classifier.fit(X_train, y_train)
predictions = popularity_classifier.predict(X_test)
accuracy_score(y_true = y_test, y_pred = predictions)
accuracy=(accuracy_score(y_true = y_test, y_pred = predictions))
accuracy=100*accuracy
X_testCopy = X_test.copy()
X_testCopy["Popular?"] = y_test
d=list(popAppsCopy['Category'])
list1=X_testCopy[X_testCopy["Popular?"] ==1]['Category'].unique()
list2=[None]*len(list1)
for i in list1:
list2[i]=df_app[d.index(i)]
list2=list(filter(None,list2))
list2=np.array(list2)
popular_categories=list(np.unique(list2))
text=""
# print(len(strong_cor))
for a in strong_cor:
text= text + str(a) + ", "
text= "" +str(popular_apps) + " among all. Therefore, with an accuracy of " +str(accuracy) +"%. \n"
for a in popular_categories:
text=text + str(a)+','
text=text+ " categories are trending."
return text
def main8():
global screen8
screen8=tk.Toplevel(screenc1)
adjustWindow(screen8,screen8)
screen8.title('Prediction')
ans=text_parameters(1)
plot1()
plot2()
plot3()
a1=tk.Label(screen8, text='CATEGORY PREDICTION', font=("Open Sans", 12,'bold'), fg='black',bg='#ffff00')
a1.pack(side=TOP,fill=X)
a2=tk.Label(screen8, text=ans, font=("Open Sans", 12,'bold'), fg='black',bg='#66ff33')
a2.pack(side=TOP,pady=5,fill=X)
a3=tk.Label(screen8, text='Amongst sports, entertainment,social media,news,events,travel and games. \n\nGAME Category has the most steady growth in recent years.\nHence is most likely to be downloaded in the coming years.', font=("Open Sans", 12,'bold'), fg='black',bg='#66ff33')
a3.pack(side=TOP,pady=20,fill=X)
path1 = "game.png"
img1=Image.open(path1)
img1 = ImageTk.PhotoImage(img1, master=screen8)
panel1 = tk.Label(screen8, image = img1)
panel1.place(x=50,y=250)
path2 = "entertainment.png"
img2=Image.open(path2)
img2 = ImageTk.PhotoImage(img2, master=screen8)
panel2 = tk.Label(screen8, image = img2)
panel2.place(x=540,y=250)
path3 = "events.png"
img3=Image.open(path3)
img3 = ImageTk.PhotoImage(img3, master=screen8)
panel3 = tk.Label(screen8, image = img3)
panel3.place(x=1030,y=250)
b1=tk.Button(screen8, text="HOME",bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screenc1.destroy)
b1.place(x=0,y=0)
b2=tk.Button(screen8,text='<<<BACK',bg='#0066ff',fg='white',font=("Calibri", 15,'bold'),width='10',command=screen8.destroy)
b2.place(x=110,y=0)
screen8.mainloop()
###===============================7========================
def plot7():
df= pd.read_excel('googleplaystore_App_data.xlsx')
df=df.set_index("App")
df=df.drop('Life Made WI-Fi Touchscreen Photo Frame',axis=0)
df=df.dropna()
Installs=[]
df['Installs']=df['Installs'].str.rstrip('+')
df['Installs']=df['Installs'].str.replace(',','').astype(float)
df=df.dropna()
for i in df['Installs']:
Installs.append(int(i))
n=df['Android Ver']
s=Installs
num=['V','A']
v=[None]*len(n)
d=[None]*len(n)
for i in range(0,len(n)):
if re.search('^V',str(n[i])):
v[i]=s[i]
else:
d[i]=s[i]
a=[None]*2
a[0]=sum(list(filter(None, v)))
a[1]=sum(list(filter(None, d)))
g=sns.barplot(x=a, y=num, palette='husl')
plt.title('Android Version type vs. downloads',fontsize=10)
plt.xlabel('Installs', fontsize = 10)
plt.ylabel('Android Version', fontsize = 10)
fig=g.get_figure()
fig.savefig('a.png')
Image.open('a.png').save('a.png','PNG')
plt.close()
def q7():
global percent_increase
df= pd.read_excel('googleplaystore_App_data.xlsx')
df=df.set_index("App")
df=df.drop('Life Made WI-Fi Touchscreen Photo Frame',axis=0)
df=df.dropna()
df=df.reset_index()
df['Installs']=df['Installs'].str.rstrip('+')
df['Installs']=df['Installs'].str.replace(',','').astype(float)
df=df.dropna()
data={'App':df['App'],'andv':df['Android Ver'],'Installs':df['Installs']}
df1=pd.DataFrame(data)
df1 = df1[(df1.andv =='Varies with device') ]
list1=[]
for i in df1['Installs']:
list1.append(i)
var1=sum(list1)
df2=pd.DataFrame(data)
df2 = df2[(df2.andv !='Varies with device') ]
list2=[]
for i in df2['Installs']:
list2.append(i)
var2=sum(list2)
percent_increase=((var1-var2)/(var1+var2))*100
def main7():
global screen7
screen7=tk.Toplevel(screent1)
screen7.title("Installs vs App Size")
adjustWindow(screen7,screen7)
plot7()
q7()
l2=tk.Label(screen7,text='App Version And Installs', width='10', height="3", font=("Calibri", 15,'bold'), fg='black', bg='#66ff33')
l2.pack(fill=X)
path = "a.png"
img=Image.open(path)
img=img.resize((650,650),Image.ANTIALIAS)
img = ImageTk.PhotoImage(img, master=screen7)
panel = tk.Label(screen7, image = img)
panel.place(x=100,y=150)
s11=round(percent_increase,1)
l1=tk.Label(screen7,text='All those apps , whose android version is not an issue and can work with varying devices.\nThere is {0}% increase in downloads'.format(s11), font=("Calibri", 12,'bold'), fg='white', bg='#3d04cf')
l1.place(x=800,y=250)