-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyt_stats.py
More file actions
1005 lines (765 loc) · 48.4 KB
/
yt_stats.py
File metadata and controls
1005 lines (765 loc) · 48.4 KB
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 tkinter as tk
import customtkinter as ctk
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg # enbales to place the graph into my window
plt.style.use("dark_background")
# CHANNELS
# [0] category = 'Film and Animation'
# [1] join_date = '2017-05-21'
# [2] channel_id = 'UCBJuEqXfXTdcPSbGO9qqn1g'
# [3] channel_name = 'MagnusNation'
# [4] subscribers = '65100'
# [5] videos = '28'
# [6] subscriber_rank = '231223.0'
# TIMESERIES
# [0] channel_id
# [1] category
# [2] datetime
# [3] views
# [4] delta_views
# [5] subscribers
# [6] delta_subscribers
# [7] videos
# [8] delta_videos
# [9] activity
class Data_analyzer:
def __init__(self):
self.main_window = ctk.CTk()
self.main_window.geometry("1280x720")
self.left_frame = ctk.CTkFrame(self.main_window, width=230, fg_color="#100f0f", corner_radius=0)
self.left_frame.pack(side="left", fill="y")
self.middle_frame = ctk.CTkFrame(self.main_window, width=1, fg_color="#575653", border_width=1, border_color="#575653", corner_radius=0)
self.middle_frame.pack(side="left", fill="y")
self.right_frame = ctk.CTkFrame(self.main_window, fg_color="#1C1B1A", corner_radius=0)
self.right_frame.pack(side="left", fill="both", expand=True)
def clear_window(self):
keep = [self.overview_button, self.leaderboard_button, self.categories_button, self.subgrowth_button, self.left_frame, self.middle_frame, self.right_frame,
self.general_label, self.analysis_label, self.efficiency_button, self.outliers_button, self.tools_label, self.rank_button, self.scatter_button]
for w in self.main_window.winfo_children(): # goes through 'widgets' created insie main_window
if w not in keep:
w.destroy()
plt.close('all')
def style_ax(self, ax, fig):
ax.tick_params(axis='x', colors='#FFFCF0')
ax.tick_params(axis='y', colors='#FFFCF0')
ax.spines['bottom'].set_color('#CECDC3')
ax.spines['left'].set_color('#CECDC3')
ax.spines['top'].set_color('#CECDC3')
ax.spines['right'].set_color('#CECDC3')
fig.patch.set_facecolor('#100f0f')
ax.set_facecolor('#100f0f')
def main_menu(self):
# TEXT
self.general_label = ctk.CTkLabel(self.main_window, text="General", fg_color="#100f0f", font = ('', 15), text_color="#878580")
self.general_label.place(x=15, y=10)
# MENU BUTTONS
self.overview_button = ctk.CTkButton(self.main_window, height=40, width=200, text = 'Overview', corner_radius=8,
border_width=1, border_color='#575653', fg_color='#1C1B1A', bg_color="#100f0f", hover_color="#282726", anchor='w', font = ('', 15),
command = lambda: self.overview_menu())
self.overview_button.place(x=15, y=45)
self.leaderboard_button = ctk.CTkButton(self.main_window, height=40, width=200, text = 'Leaderboard', corner_radius=8,
border_width=1, border_color='#575653', fg_color='#1C1B1A', bg_color="#100f0f", hover_color="#282726", anchor='w', font = ('', 15),
command = lambda: self.leaderboard_menu())
self.leaderboard_button.place(x=15, y=90)
self.categories_button = ctk.CTkButton(self.main_window, height=40, width=200, text = 'Categories', corner_radius=8,
border_width=1, border_color='#575653', fg_color='#1C1B1A', bg_color="#100f0f", hover_color="#282726", anchor='w', font = ('', 15),
command = lambda: self.categories_menu())
self.categories_button.place(x=15, y=135)
# TEXT
self.analysis_label = ctk.CTkLabel(self.main_window, text="Analysis", fg_color="#100f0f", font = ('', 15), text_color="#878580")
self.analysis_label.place(x=15, y=195)
self.subgrowth_button = ctk.CTkButton(self.main_window, height=40, width=200, text = 'Subscriber Growth', corner_radius=8,
border_width=1, border_color='#575653', fg_color='#1C1B1A', bg_color="#100f0f", hover_color="#282726", anchor='w', font = ('', 15),
command = lambda: self.subgrowth_menu())
self.subgrowth_button.place(x=15, y=230)
self.efficiency_button = ctk.CTkButton(self.main_window, height=40, width=200, text = 'Efficiency', corner_radius=8,
border_width=1, border_color='#575653', fg_color='#1C1B1A', bg_color="#100f0f", hover_color="#282726", anchor='w', font = ('', 15),
command = lambda: self.efficiency_menu())
self.efficiency_button.place(x=15, y=275)
self.outliers_button = ctk.CTkButton(self.main_window, height=40, width=200, text = 'Outliers', corner_radius=8,
border_width=1, border_color='#575653', fg_color='#1C1B1A', bg_color="#100f0f", hover_color="#282726", anchor='w', font = ('', 15),
command = lambda: self.outliers_menu())
self.outliers_button.place(x=15, y=320)
self.scatter_button = ctk.CTkButton(self.main_window, height=40, width=200, text = 'Age vs Success', corner_radius=8,
border_width=1, border_color='#575653', fg_color='#1C1B1A', bg_color="#100f0f", hover_color="#282726", anchor='w', font = ('', 15),
command = lambda: self.agevssuccess_menu())
self.scatter_button.place(x=15, y=365)
# TEXT
self.tools_label = ctk.CTkLabel(self.main_window, text="Tools", fg_color="#100f0f", font = ('', 15), text_color="#878580")
self.tools_label.place(x=15, y=425)
self.rank_button = ctk.CTkButton(self.main_window, height=40, width=200, text = 'Rank Yourself', corner_radius=8,
border_width=1, border_color='#575653', fg_color='#1C1B1A', bg_color="#100f0f", hover_color="#282726", anchor='w', font = ('', 15),
command = lambda: self.rank_menu())
self.rank_button.place(x=15, y=460)
def overview_menu(self):
self.clear_window()
# TITLES
title_label = ctk.CTkLabel(self.main_window, text="Overview", fg_color="#1C1B1A", font = ('Courier New', 40, 'bold'), text_color="#FFFCF0")
title_label.place(x=260, y=25)
title_label = ctk.CTkLabel(self.main_window, text="Data available - 2016 to 2019", fg_color="#1C1B1A", font = ('Courier New', 15), text_color="#878580")
title_label.place(x=260, y=65)
# INFO
## CHANNEL AMOUNT
frame = ctk.CTkFrame(self.main_window, width=250, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=260, y=120)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
channel_amount_label = ctk.CTkLabel(frame, text="Total Channels", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
channel_amount_label.pack(anchor='w', padx=20, pady=(15, 0))
channel_amount = 0
for row in self.channels:
channel_amount += 1
channel_amount_label = ctk.CTkLabel(frame, text=str(channel_amount), fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
channel_amount_label.pack(anchor='w', padx=20, pady=(0, 20))
## CATEGORY AMOUNT
frame = ctk.CTkFrame(self.main_window, width=250, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=525, y=120)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
categories_amount_label = ctk.CTkLabel(frame, text="Categories", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
categories_amount_label.pack(anchor='w', padx=20, pady=(15, 0))
categories_count_list = []
categories_count = 0
for row in self.channels:
parts = row.split('\t')
if parts[0] not in categories_count_list:
categories_count_list.append(parts[0])
categories_count += 1
categories_amount_label = ctk.CTkLabel(frame, text=str(categories_count), fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
categories_amount_label.pack(anchor='w', padx=20, pady=(0, 20))
## AVG SUBS
frame = ctk.CTkFrame(self.main_window, width=250, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=790, y=120)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
subs_amount_label = ctk.CTkLabel(frame, text="Avg. Subscribers", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
subs_amount_label.pack(anchor='w', padx=20, pady=(15, 0))
row_count = 0
sub_storage = 0
for row in self.channels:
parts = row.split('\t')
row_count += 1
sub_storage += int(parts[4])
subs_amount_label = ctk.CTkLabel(frame, text=str(self.letterform(sub_storage//row_count)), fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
subs_amount_label.pack(anchor='w', padx=20, pady=(0, 20))
s.overview_bargraph()
def leaderboard_menu(self):
self.clear_window()
# TITLES
title_label = ctk.CTkLabel(self.main_window, text="Leaderbord", fg_color="#1C1B1A", font = ('Courier New', 40, 'bold'), text_color="#FFFCF0")
title_label.place(x=260, y=25)
title_label = ctk.CTkLabel(self.main_window, text="Shows the top channels based on subscriber count during this period", fg_color="#1C1B1A", font = ('Courier New', 15), text_color="#878580")
title_label.place(x=260, y=65)
frame = ctk.CTkFrame(self.main_window, width=900, height=50, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=260, y=120)
frame = ctk.CTkFrame(self.main_window, width=900, height=450, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=260, y=180)
y_gain = 133
for i in range (10 + 1):
channels = self.channels[i-1]
parts = channels.split('\t')
if i == 0:
name = 'Channel'
category = 'Category'
subscribers = 'Subs'
videos = 'Videos'
join_date = 'Join Date'
else:
name = parts[3]
category = parts[0]
subscribers = self.letterform(parts[4])
videos = self.letterform(parts[5])
join_date = parts[1][:4]
channel_amount_label = ctk.CTkLabel(self.main_window, text=str(i), fg_color="#100f0f", font = ('Courier New', 20), text_color="#FFFCF0")
channel_amount_label.place(x=280, y = y_gain)
channel_amount_label = ctk.CTkLabel(self.main_window, text=name, fg_color="#100f0f", font = ('Courier New', 20, 'bold'), text_color="#FFFCF0")
channel_amount_label.place(x=320, y = y_gain)
channel_amount_label = ctk.CTkLabel(self.main_window, text=category, fg_color="#100f0f", font = ('Courier New', 20), text_color="#FFFCF0")
channel_amount_label.place(x=620, y = y_gain)
channel_amount_label = ctk.CTkLabel(self.main_window, text=subscribers, fg_color="#100f0f", font = ('Courier New', 20), text_color="#FFFCF0")
channel_amount_label.place(x=820, y = y_gain)
channel_amount_label = ctk.CTkLabel(self.main_window, text=videos, fg_color="#100f0f", font = ('Courier New', 20), text_color="#FFFCF0")
channel_amount_label.place(x=920, y = y_gain)
channel_amount_label = ctk.CTkLabel(self.main_window, text=join_date, fg_color="#100f0f", font = ('Courier New', 20), text_color="#FFFCF0")
channel_amount_label.place(x=1020, y = y_gain)
if i == 0:
y_gain += 63
else:
y_gain += 30
def categories_menu(self):
self.clear_window()
# TITLES
title_label = ctk.CTkLabel(self.main_window, text="Category Representation", fg_color="#1C1B1A", font = ('Courier New', 40, 'bold'), text_color="#FFFCF0")
title_label.place(x=260, y=25)
title_label = ctk.CTkLabel(self.main_window, text="Pie graph shows how each category is represented on YouTube", fg_color="#1C1B1A", font = ('Courier New', 15), text_color="#878580")
title_label.place(x=260, y=65)
s.categories_piegraph('Category Representation')
# INFO
## MOST COMMON
frame = ctk.CTkFrame(self.main_window, width=250, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=990, y=120)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
common_amount_label = ctk.CTkLabel(frame, text="Most Common", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
common_amount_label.pack(anchor='w', padx=20, pady=(15, 0))
common_amount_label = ctk.CTkLabel(frame, text=self.most_common_category_name, fg_color="#100f0f", font = ('Courier New', 25, 'bold'), text_color="#FFFCF0")
common_amount_label.pack(anchor='w', padx=20, pady=(0, 20))
## AVG
frame = ctk.CTkFrame(self.main_window, width=250, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=990, y=260)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
row_count = 0
sub_storage = 0
video_storage = 0
for row in self.channels:
parts = row.split('\t')
if parts[0] == self.most_common_category_name:
row_count += 1
sub_storage += int(parts[4])
video_storage += int(parts[5])
subavg_label = ctk.CTkLabel(frame, text="Total Subscribers", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
subavg_label.pack(anchor='w', padx=20, pady=(15, 0))
subavg_label = ctk.CTkLabel(frame, text=str(self.letterform(sub_storage)), fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
subavg_label.pack(anchor='w', padx=20, pady=(0, 20))
## Channel amount
frame = ctk.CTkFrame(self.main_window, width=250, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=990, y=400)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
channel_amount_label = ctk.CTkLabel(frame, text="Channels", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
channel_amount_label.pack(anchor='w', padx=20, pady=(15, 0))
channel_amount_label = ctk.CTkLabel(frame, text=str(row_count), fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
channel_amount_label.pack(anchor='w', padx=20, pady=(0, 20))
## Video amount
frame = ctk.CTkFrame(self.main_window, width=250, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=990, y=540)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
channel_amount_label = ctk.CTkLabel(frame, text="Total Videos", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
channel_amount_label.pack(anchor='w', padx=20, pady=(15, 0))
channel_amount_label = ctk.CTkLabel(frame, text=str(self.letterform(video_storage)), fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
channel_amount_label.pack(anchor='w', padx=20, pady=(0, 20))
def subgrowth_menu(self):
self.clear_window()
# TITLES
title_label = ctk.CTkLabel(self.main_window, text="Subscriber Growth", fg_color="#1C1B1A", font = ('Courier New', 40, 'bold'), text_color="#FFFCF0")
title_label.place(x=260, y=25)
title_label = ctk.CTkLabel(self.main_window, text="Line graph shows subscriber growth from 2016 to 2019", fg_color="#1C1B1A", font = ('Courier New', 15), text_color="#878580")
title_label.place(x=260, y=65)
listbox_frame = ctk.CTkFrame(self.main_window, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
listbox_frame.place(x=260, y=120)
self.load_channel_listbox(listbox_frame)
self.channel_listbox.bind("<<ListboxSelect>>", lambda event: self.subgrowth_linegraph(5, 2, 'Subscribers vs Date')) # graph creation upon clicking channel in the listbox wihtout any external input
self.channel_listbox.selection_set(0, 1)
self.subgrowth_linegraph(5, 2, 'Subscribers vs Date') # empty graph so there isn't blank space
def efficiency_menu(self):
self.clear_window()
# TITLES
title_label = ctk.CTkLabel(self.main_window, text="Efficiency", fg_color="#1C1B1A", font = ('Courier New', 40, 'bold'), text_color="#FFFCF0")
title_label.place(x=260, y=25)
title_label = ctk.CTkLabel(self.main_window, text="How efficient are channels based on the amount of views per video", fg_color="#1C1B1A", font = ('Courier New', 15), text_color="#878580")
title_label.place(x=260, y=65)
listbox_frame = ctk.CTkFrame(self.main_window, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
listbox_frame.place(x=260, y=120)
self.load_channel_listbox(listbox_frame)
self.channel_listbox.bind("<<ListboxSelect>>", lambda event: self.channel_efficiency_linegraph(7, 3, 'Views vs Videos')) # graph creation upon clicking channel in the listbox wihtout any external input
self.channel_listbox.selection_set(0, 2)
self.channel_efficiency_linegraph(7, 3, 'Views vs Videos') # eliminated blank space
def outliers_menu(self):
self.clear_window()
# TITLES:
title_label = ctk.CTkLabel(self.main_window, text="Outliers", fg_color="#1C1B1A", font = ('Courier New', 40, 'bold'), text_color="#FFFCF0")
title_label.place(x=260, y=25)
title_label_2 = ctk.CTkLabel(self.main_window, text="Over-performing channels, ranking equation lies in subscriber amount divided by total video amount",
fg_color="#1C1B1A", font = ('Courier New', 15), text_color="#878580")
title_label_2.place(x=260, y=65)
listbox_frame = ctk.CTkFrame(self.main_window, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
listbox_frame.place(x=260, y=120)
self.load_categories_listbox(listbox_frame)
def outliers_output():
keep = [self.overview_button, self.leaderboard_button, self.categories_button, self.subgrowth_button, self.left_frame, self.middle_frame, self.right_frame,
self.general_label, self.analysis_label, self.efficiency_button, self.outliers_button, self.tools_label, self.rank_button,
listbox_frame, title_label, title_label_2, self.scatter_button]
for w in self.main_window.winfo_children(): # goes through 'widgets' created insie main_window
if w not in keep:
w.destroy()
efficiency_value = 0
for row in self.channels:
parts = row.split('\t')
if parts[0] == self.category_listbox.get(self.category_listbox.curselection()):
efficiency = int(parts[4])//int(parts[5])
if efficiency > efficiency_value:
efficiency_value = efficiency
top_performer = parts[3]
# CATEGORY NAME
frame = ctk.CTkFrame(self.main_window, width=700, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=510, y=120)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
category_label = ctk.CTkLabel(frame, text="Category", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
category_label.pack(anchor='w', padx=20, pady=(15, 0))
cateogry_label = ctk.CTkLabel(frame, text=self.category_listbox.get(self.category_listbox.curselection()),
fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
cateogry_label.pack(anchor='w', padx=20, pady=(0, 20))
# OUTLIER NAME
frame = ctk.CTkFrame(self.main_window, width = 435, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=510, y=255)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
outlier_label = ctk.CTkLabel(frame, text="Top Performer", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
outlier_label.pack(anchor='w', padx=20, pady=(15, 0))
outlier_label = ctk.CTkLabel(frame, text=top_performer,
fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
outlier_label.pack(anchor='w', padx=20, pady=(0, 20))
for row in self.channels:
parts = row.split('\t')
if parts[3] == top_performer:
subscribers = parts[4]
videos = parts[5]
join_date = parts[1][:12]
# EXTRAS
frame = ctk.CTkFrame(self.main_window, width=435, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=775, y=390)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
common_amount_label = ctk.CTkLabel(frame, text='Join Date', fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
common_amount_label.pack(anchor='w', padx=20, pady=(15, 0))
common_amount_label = ctk.CTkLabel(frame, text=join_date, fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
common_amount_label.pack(anchor='w', padx=20, pady=(0, 20))
frame = ctk.CTkFrame(self.main_window, width=250, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=960, y=255)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
subscriber_amount_label = ctk.CTkLabel(frame, text='Subscribers', fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
subscriber_amount_label.pack(anchor='w', padx=20, pady=(15, 0))
subscriber_amount_label = ctk.CTkLabel(frame, text=self.letterform(subscribers), fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
subscriber_amount_label.pack(anchor='w', padx=20, pady=(0, 20))
frame = ctk.CTkFrame(self.main_window, width=250, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=510, y=390)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
video_amount_label = ctk.CTkLabel(frame, text='Videos', fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
video_amount_label.pack(anchor='w', padx=20, pady=(15, 0))
video_amount_label = ctk.CTkLabel(frame, text=self.letterform(videos), fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
video_amount_label.pack(anchor='w', padx=20, pady=(0, 20))
plt.close('all') # now the graphs wont be on top of each other and multiple, but just one
fig, ax = plt.subplots()
fig.subplots_adjust(left=-0.045, right=1.045)
x_value = []
y_value = []
for row in self.timeseries:
parts = row.split('\t')
# Check just the ones selected in the ListBox
if top_performer == self.channel_dict[parts[0]]:
y_value.append(float(parts[3]))
x_value.append(parts[3][:10]) # also remove hour and minute, [start:stop]
ax.fill_between(x_value, y_value, color = '#1C1B1A', edgecolor = '#878580')
ax.set_xticks(x_value[::35]) # [start:stop:step]
frame = ctk.CTkFrame(self.main_window, width=700, height=165, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=510, y=525)
frame.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
ax.tick_params(axis='x', colors='#100f0f')
ax.tick_params(axis='y', colors='#100f0f')
ax.spines['bottom'].set_color('#100f0f')
ax.spines['left'].set_color('#100f0f')
ax.spines['top'].set_color('#100f0f')
ax.spines['right'].set_color('#100f0f')
fig.patch.set_facecolor('#100f0f')
ax.set_facecolor('#100f0f')
# put the graph into canvas so it can be shown inside the customtikinter's frame inside its window
canvas = FigureCanvasTkAgg(fig, master=frame)
widget = canvas.get_tk_widget()
# fig.subplots_adjust(left = 0.05, right = 0.95, bottom = 0.05, top = 0.95) # from 0 to 1, from start to end of the window
widget.pack(padx=5, pady=5) # pad so rounded corners work
self.category_listbox.bind("<<ListboxSelect>>", lambda event: outliers_output()) # graph creation upon clicking channel in the listbox wihtout any external input
# pre-select first item
self.category_listbox.selection_set(13)
outliers_output()
def agevssuccess_menu(self):
self.clear_window()
# TITLES
title_label = ctk.CTkLabel(self.main_window, text="Does Age Matter?", fg_color="#1C1B1A", font = ('Courier New', 40, 'bold'), text_color="#FFFCF0")
title_label.place(x=260, y=25)
title_label = ctk.CTkLabel(self.main_window, text="Mind the fact that many channels didn't upload for years after the initial creation", fg_color="#1C1B1A", font = ('Courier New', 15), text_color="#878580")
title_label.place(x=260, y=65)
listbox_frame = ctk.CTkFrame(self.main_window, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
listbox_frame.place(x=260, y=120)
self.load_channel_listbox(listbox_frame)
self.channel_listbox.bind("<<ListboxSelect>>", lambda event: self.agevssuccess_scattergraph(4, 1, 'Subscribers vs Join Date')) # graph creation upon clicking channel in the listbox wihtout any external input
self.channel_listbox.selection_set(0, 5)
self.agevssuccess_scattergraph(4, 1, 'Subscribers vs Join Date') # empty graph so there isn't blank space
def rank_menu(self):
self.clear_window()
# TITLES
title_label = ctk.CTkLabel(self.main_window, text="Rank Yourself", fg_color="#1C1B1A", font = ('Courier New', 40, 'bold'), text_color="#FFFCF0")
title_label.place(x=260, y=25)
title_label_2 = ctk.CTkLabel(self.main_window, text="Enter your channel statistics to see where you would rank in the dataset", fg_color="#1C1B1A", font = ('Courier New', 15), text_color="#878580")
title_label_2.place(x=260, y=65)
frame = ctk.CTkFrame(self.main_window, width=700, height=100, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame.place(x=260, y=120)
categories_list = []
for row in self.channels:
parts = row.split('\t')
if parts[0] not in categories_list:
categories_list.append(parts[0])
title_label_3 = ctk.CTkLabel(self.main_window, text="Category", fg_color="#100f0f", font = ('Courier New', 16), text_color="#878580")
title_label_3.place(x=295, y = 140)
category_combo = ctk.CTkComboBox(frame, values=categories_list, width = 200, height = 40, state = 'readonly', font = ('', 18, 'bold'),
fg_color="#1C1B1A",
border_color="#575653",
dropdown_fg_color="#282726",
button_color="#575653")
category_combo.pack(side = 'left', padx = (30, 30), pady = (50, 30))
title_label_4 = ctk.CTkLabel(self.main_window, text="Subscribers", fg_color="#100f0f", font = ('Courier New', 16), text_color="#878580")
title_label_4.place(x=525, y = 140)
subs_entry = ctk.CTkEntry(frame, width=200, height=40, placeholder_text='eg. 9000000', font = ('', 18, 'bold'),
fg_color="#1C1B1A",
border_color="#575653")
subs_entry.pack(side = 'left', padx = (0, 30), pady = (50, 30))
title_label_5 = ctk.CTkLabel(self.main_window, text="Videos", fg_color="#100f0f", font = ('Courier New', 16), text_color="#878580")
title_label_5.place(x=755, y = 140)
video_entry = ctk.CTkEntry(frame, width=200, height=40, placeholder_text='eg. 110', font = ('', 18, 'bold'),
fg_color="#1C1B1A",
border_color="#575653")
video_entry.pack(side = 'left', padx = (0, 30), pady = (50, 30))
# ENTRY BUTTON
frame2 = ctk.CTkFrame(self.main_window, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame2.place(x=1010, y=120)
rank_button = ctk.CTkButton(frame2, height=60, width=150, text = 'RANK', corner_radius=8,
border_width=1, border_color='#575653', fg_color='#1C1B1A', bg_color="#100f0f", hover_color="#282726", font = ('', 40, 'bold'),
command = lambda: rank_output())
rank_button.pack(padx = 30, pady = 30)
def rank_output():
# isdigit does not allow negatives or decimals which is nice
if category_combo.get() != '' and subs_entry.get().isdigit() and video_entry.get().isdigit() and int(subs_entry.get()) > 0 and int(video_entry.get()) > 0:
keep = [self.overview_button, self.leaderboard_button, self.categories_button, self.subgrowth_button, self.left_frame, self.middle_frame, self.right_frame,
self.general_label, self.analysis_label, self.efficiency_button, self.outliers_button, self.tools_label, self.rank_button,
self.scatter_button, category_combo, subs_entry, video_entry, frame, frame2, title_label, title_label_2, title_label_3, title_label_4, title_label_5, rank_button]
for w in self.main_window.winfo_children(): # goes through 'widgets' created insie main_window
if w not in keep:
w.destroy()
higher_subs_cat = 0
all_subs_cat = 0
higher_subs = 0
all_subs = 0
for row in self.channels:
parts = row.split('\t')
all_subs +=1
if int(parts[4]) > int(subs_entry.get()):
higher_subs +=1
if parts[0] == category_combo.get():
if int(parts[4]) > int(subs_entry.get()):
higher_subs_cat += 1
all_subs_cat += 1
frame3 = ctk.CTkFrame(self.main_window, width=300, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame3.place(x=260, y=270)
frame3.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
subscriber_rank_label = ctk.CTkLabel(frame3, text=f"Subscriber Rank in {category_combo.get()}", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
subscriber_rank_label.pack(anchor='w', padx=20, pady=(15, 0))
subscriber_rank_label = ctk.CTkLabel(frame3, text=f'Top {int((higher_subs_cat/all_subs_cat) * 100)}%', fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
subscriber_rank_label.pack(anchor='w', padx=20, pady=(0, 20))
frame3 = ctk.CTkFrame(self.main_window, width=300, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame3.place(x=590, y=270)
frame3.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
subscriber_rank_label = ctk.CTkLabel(frame3, text="Overall Subscriber Rank", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
subscriber_rank_label.pack(anchor='w', padx=20, pady=(15, 0))
subscriber_rank_label = ctk.CTkLabel(frame3, text=f'Top {int((higher_subs/all_subs) * 100)}%', fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
subscriber_rank_label.pack(anchor='w', padx=20, pady=(0, 20))
higher_eff = 0
all_eff = 0
for row in self.channels:
parts = row.split('\t')
if int(parts[5])/int(parts[4]) < int(video_entry.get())/int(subs_entry.get()):
higher_eff += 1
all_eff += 1
frame3 = ctk.CTkFrame(self.main_window, width=300, height=120, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame3.place(x=920, y=270)
frame3.pack_propagate(False) # insides can be packed without changing the frame size to have consistency in the gui
subscriber_rank_label = ctk.CTkLabel(frame3, text="Video Amount Efficiency", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
subscriber_rank_label.pack(anchor='w', padx=20, pady=(15, 0))
subscriber_rank_label = ctk.CTkLabel(frame3, text=f'Top {int((higher_eff/all_eff) * 100)}%', fg_color="#100f0f", font = ('Courier New', 50, 'bold'), text_color="#FFFCF0")
subscriber_rank_label.pack(anchor='w', padx=20, pady=(0, 20))
self.categories_linegraph(category_combo.get())
subscriber_rank_label = ctk.CTkLabel(self.main_window, text="Subscriber Performance Over Time for Your Category", fg_color="#100f0f", font = ('Courier New', 15), text_color="#878580")
subscriber_rank_label.place(x=280, y = 435)
def categories_linegraph(self, category):
fig, ax = plt.subplots()
fig.subplots_adjust(left=0, right=1)
frame3 = ctk.CTkFrame(self.main_window, width=960, height=270, fg_color="#100f0f", bg_color='#1C1B1A', corner_radius=12)
frame3.place(x=260, y=420)
frame3.pack_propagate(False)
y_value = []
x_value_dict = {}
x_value = []
for row in self.timeseries:
parts = row.split('\t')
if parts[1] == category:
if parts[2][:10] not in x_value:
x_value_dict[parts[2][:10]] = 0
x_value_dict[parts[2][:10]] += float(parts[5])
x_value_dict = dict(sorted(x_value_dict.items())) # sorts the items by date becuase of the inconsistent amount od data
for key in x_value_dict:
x_value.append(key)
y_value.append(int(x_value_dict[key]))
ax.fill_between(x_value, y_value, color = '#1C1B1A', edgecolor = '#878580')
ax.tick_params(axis='x', colors='#100f0f')
ax.tick_params(axis='y', colors='#100f0f')
ax.spines['bottom'].set_color('#100f0f')
ax.spines['left'].set_color('#100f0f')
ax.spines['top'].set_color('#100f0f')
ax.spines['right'].set_color('#100f0f')
fig.patch.set_facecolor('#100f0f')
ax.set_facecolor('#100f0f')
# put the graph into canvas so it can be shown inside the customtikinter's frame inside its window
canvas = FigureCanvasTkAgg(fig, master=frame3)
widget = canvas.get_tk_widget()
widget.pack(fill = 'both', padx=5, pady=5) # pad so rounded corners work
def overview_bargraph(self):
frame = ctk.CTkFrame(
self.main_window,
fg_color="#100f0f",
bg_color="#1C1B1A",
corner_radius=12
)
frame.place(x=260, y=270)
categories_subs_dict = {}
categories_count_dict = {}
for row in self.channels:
parts = row.split('\t')
if parts[0] not in categories_subs_dict:
categories_subs_dict[parts[0]] = 0
categories_count_dict[parts[0]] = 0
categories_subs_dict[parts[0]] += int(parts[4])
categories_count_dict[parts[0]] += 1
category_name = []
category_subs = []
for category in categories_subs_dict:
avg = categories_subs_dict[category] // categories_count_dict[category]
if categories_count_dict[category] > 30:
if len(category_name) < 12:
category_name.append(category)
category_subs.append(avg)
fig, ax = plt.subplots(figsize=(9, 4.1))
ax.barh(category_name, category_subs, color = '#1C1B1A', edgecolor = '#878580')
fig.subplots_adjust(left = 0.18, right = 0.95, bottom = 0.14) # from 0 to 1, from start to end of the window
ax.set_title("Categories vs Subscribers", color='#FFFCF0')
self.style_ax(ax, fig)
# put the graph into canvas so it can be shown inside the customtikinter's frame inside its window
canvas = FigureCanvasTkAgg(fig, master=frame)
widget = canvas.get_tk_widget()
widget.pack(padx=5, pady=5) # pad so rounded corners work
def categories_piegraph(self, title):
plt.close('all') # now the graphs wont be on top of each other and multiple, but just one
fig, ax = plt.subplots(figsize=(7, 5.32))
categories_count_dict = {}
categories_count_list = []
categories_name_list = []
for row in self.channels:
parts = row.split('\t')
if parts[0] not in categories_count_dict:
categories_count_dict[parts[0]] = 0
categories_count_dict['Others'] = 0 # Add Others to accomodate for low count categories in pie graph
for row in self.channels:
parts = row.split('\t')
for category_name in categories_count_dict:
if category_name == parts[0]:
categories_count_dict[category_name] += 1
for category_name in categories_count_dict:
if categories_count_dict[category_name] > 20:
categories_name_list.append(category_name)
categories_count_list.append(categories_count_dict[category_name])
else:
categories_count_dict['Others'] += categories_count_dict[category_name]
frame = ctk.CTkFrame(
self.main_window,
fg_color="#100f0f",
bg_color="#1C1B1A",
corner_radius=12,
)
frame.place(x=260, y=120)
ax.pie(
categories_count_list,
labels=categories_name_list,
autopct='%1.1f%%',
textprops={'color': '#FFFCF0'},
shadow=True,
)
ax.set_title(title, color='#FFFCF0')
fig.patch.set_facecolor('#100f0f') #whole
ax.set_facecolor('#100f0f') # inside of the graph
for category_name in categories_count_dict:
if categories_count_dict[category_name] == max(categories_count_list):
self.most_common_category_name = category_name
# put the graph into canvas so it can be shown inside the customtikinter's frame inside its window
canvas = FigureCanvasTkAgg(fig, master=frame)
widget = canvas.get_tk_widget()
widget.pack(padx=5, pady=5) # pad so rounded corners work
def subgrowth_linegraph(self, y_part_value, x_part_value, title):
plt.close('all') # now the graphs wont be on top of each other and multiple, but just one
fig, ax = plt.subplots(figsize=(7.2, 5.6))
selected_channels = self.channel_listbox.curselection()
chosen_channels = []
for index in selected_channels:
chosen_channels.append(self.channel_listbox.get(index))
for channel_name in chosen_channels:
x_value = []
y_value = []
date_labels_first_count = 0
date_labels_listcheck = []
for row in self.timeseries:
parts = row.split('\t')
# Check just the ones selected in the ListBox
if channel_name == self.channel_dict[parts[0]]:
y_value.append(float(parts[y_part_value]))
x_value.append(parts[x_part_value][:10]) # also remove hour and minute, [start:stop]
# in case of inconsistent amount of data, base the x graph axis of the first selected channel
if channel_name == chosen_channels[0]:
date_labels_first_count = len(x_value)
date_labels_listcheck = x_value
if (len(x_value) == date_labels_first_count) and (x_value == date_labels_listcheck):
ax.plot(x_value, y_value, label=channel_name)
ax.set_xticks(x_value[::35]) # [start:stop:step]
else:
ax.plot(y_value, label=channel_name)
frame = ctk.CTkFrame(
self.main_window,
fg_color="#100f0f",
bg_color="#1C1B1A",
corner_radius=12,
)
frame.place(x=510, y=120)
self.style_ax(ax, fig)
ax.legend(facecolor = '#100f0f')
ax.grid(color='#343331')
# put the graph into canvas so it can be shown inside the customtikinter's frame inside its window
canvas = FigureCanvasTkAgg(fig, master=frame)
widget = canvas.get_tk_widget()
# fig.subplots_adjust(left = 0.05, right = 0.95, bottom = 0.05, top = 0.95) # from 0 to 1, from start to end of the window
widget.pack(padx=5, pady=5) # pad so rounded corners work
def channel_efficiency_linegraph(self, x_part_value, y_part_value, title):
plt.close('all') # now the graphs wont be on top of each other and multiple, but just one
fig, ax = plt.subplots(figsize=(7, 2.5))
selected_channels = self.channel_listbox.curselection()
chosen_channels = []
for index in selected_channels:
chosen_channels.append(self.channel_listbox.get(index))
frame = ctk.CTkScrollableFrame(
self.main_window,
fg_color="#100f0f",
bg_color="#1C1B1A",
corner_radius=12,
width=700,
height=546
)
frame.place(x=510, y=120)
for channel_name in chosen_channels:
x_value = []
y_value = []
for row in self.timeseries:
parts = row.split('\t')
# Check just the ones selected in the ListBox
if channel_name == self.channel_dict[parts[0]]:
y_value.append(float(parts[y_part_value]))
x_value.append(parts[x_part_value][:10]) # also remove hour and minute, [start:stop]
fig, ax = plt.subplots(figsize=(7, 2.5))
ax.plot(x_value, y_value, label=channel_name, color='#24837B')
ax.set_xticks(x_value[::35]) # [start:stop:step]
self.style_ax(ax, fig)
ax.grid(color='#343331')
# put the graph into canvas so it can be shown inside the customtikinter's frame inside its window
canvas = FigureCanvasTkAgg(fig, master=frame)
widget = canvas.get_tk_widget()
# fig.subplots_adjust(left = 0.05, right = 0.95, bottom = 0.05, top = 0.95) # from 0 to 1, from start to end of the window
widget.pack(padx=5, pady=5) # pad so rounded corners work
def agevssuccess_scattergraph(self, y_part_value, x_part_value, title):
selected_channels = self.channel_listbox.curselection()
fig, ax = plt.subplots(figsize=(7.2, 5.6))
# curselection gives int positions, need to convert to 'channel_name'
chosen_channels = []
for index in selected_channels:
chosen_channels.append(self.channel_listbox.get(index))
value_dict = {}
value_dict_2 = {}
x_value = []
y_value = []
for channel_name in chosen_channels:
for row in self.channels:
parts = row.split('\t')
if parts[3] == channel_name:
value_dict[parts[x_part_value]] = parts[y_part_value]
value_dict_2[parts[x_part_value]] = channel_name
value_dict = dict(sorted(value_dict.items()))
value_dict_2 = dict(sorted(value_dict_2.items()))
for key in value_dict:
x_value = key
y_value = (int(value_dict[key]))
name = value_dict_2[key]
ax.scatter(x_value, y_value, label=name)
frame = ctk.CTkFrame(
self.main_window,
fg_color="#100f0f",
bg_color="#1C1B1A",
corner_radius=12,
)
frame.place(x=510, y=120)
self.style_ax(ax, fig)
ax.grid(color='#282726')
ax.legend(facecolor = '#100f0f')
# put the graph into canvas so it can be shown inside the customtikinter's frame inside its window
canvas = FigureCanvasTkAgg(fig, master=frame)
widget = canvas.get_tk_widget()
# fig.subplots_adjust(left = 0.05, right = 0.95, bottom = 0.05, top = 0.95) # from 0 to 1, from start to end of the window
widget.pack(padx=5, pady=5) # pad so rounded corners work
def load_channel_dataset(self):
self.channel_dict = {}
self.channel_dict_join_date = {}
with open('datasets/channels.tsv') as f:
next(f)
self.channels = f.read().strip().split('\n')
for row in self.channels:
parts = row.split('\t')
self.channel_dict[parts[2]] = parts[3] # key = id, value = name
self.channel_dict_join_date[parts[3]] = parts[1] # key = channel_name, value = join_date
def load_timeseries_dataset(self):
with open('datasets/timeseries.tsv') as f:
next(f)
self.timeseries = f.read().strip().split('\n')
def load_categories_listbox(self, frame):
self.category_listbox = tk.Listbox(frame,
bg="#100f0f",
fg="#FFFCF0",
selectmode='single',
selectbackground="#282726",
selectforeground="#FFFCF0",
highlightthickness=0,
borderwidth=0,
width=20,
height=25,
font=('Courier New', 13))
categories_list = []
for row in self.channels:
parts = row.split('\t')
if parts[0] not in categories_list:
categories_list.append(parts[0])
self.category_listbox.insert(tk.END, parts[0])
self.category_listbox.pack(padx=10, pady=10)
def load_channel_listbox(self, frame):
self.channel_listbox = tk.Listbox(frame,
bg="#100f0f",
fg="#FFFCF0",
selectmode='extended',
selectbackground="#282726",
selectforeground="#FFFCF0",
highlightthickness=0,
borderwidth=0,
width=20,
height=25,
font=('Courier New', 13))
for row in self.channels:
parts = row.split('\t')
self.channel_listbox.insert(tk.END, parts[3])
self.channel_listbox.pack(padx=10, pady=10)
def letterform(self, n):
n = float(n)
if n >= 1000000000:
return f"{n/1000000000:.1f}B"
if n >= 1000000:
return f"{n/1000000:.1f}M"
if n >= 1000:
return f"{n/1000:.1f}K"
return str(int(n))
s = Data_analyzer()