File size: 127,016 Bytes
4d1cb0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Twitter_API.ipynb",
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "n9mFOtjUGKmk"
      },
      "source": [
        "# Tweet mining using Twitter API via Tweepy:"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "-3bUQ54_84g8"
      },
      "source": [
        "In this notebook I am using Tweepy python library to  tweets using relevant hashtags. I was able to retrieve around 19000 unique tweets via twitter API. At the end, all the datasets with different depressive hashtags will be combined, cleaned and saved as depressive_tweets.csv."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "1Bojm_bffNAV",
        "outputId": "92f04f31-eb1b-4c13-f811-1cad9d759a34"
      },
      "source": [
        "from google.colab import drive\n",
        "drive.mount('/content/drive')"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mounted at /content/drive\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7iWDBsjTwEyZ"
      },
      "source": [
        "## Tweets mining"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "TtZk0vyLwWwW"
      },
      "source": [
        "!pip install -qqq tweepy"
      ],
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "jobjTBDIwhUl"
      },
      "source": [
        "## Import required libraries\n",
        "import tweepy\n",
        "from tweepy.streaming import StreamListener\n",
        "from tweepy import OAuthHandler\n",
        "from tweepy import Stream\n",
        "import csv\n",
        "import pandas as pd\n",
        "\n",
        "## Access to twitter API cunsumer_key and access_secret\n",
        "#import config.ipynb"
      ],
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Dv5AsxY6iL2s"
      },
      "source": [
        "## Twitter API related information\n",
        "consumer_key = config.API_KEY\n",
        "consumer_secret = config.API_KEY_SECRET\n",
        "access_key= config.ACCESS_TOKEN\n",
        "access_secret = config.ACCESS_TOKEN_SECRET"
      ],
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "M6mSp-B_vzn-"
      },
      "source": [
        "auth = tweepy.OAuthHandler(consumer_key, consumer_secret) # Pass in Consumer key and secret for authentication by API\n",
        "auth.set_access_token(access_key, access_secret) # Pass in Access key and secret for authentication by API\n",
        "api = tweepy.API(auth,wait_on_rate_limit=True,wait_on_rate_limit_notify=True) # Sleeps when API limit is reached"
      ],
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "FHqBQHYpDcz_"
      },
      "source": [
        "## depress_tags = [\"#depressed\", \"#anxiety\", \"#depression\", \"#suicide\", \"#mentalhealth\"\n",
        "##                \"#loneliness\", \"#hopelessness\", \"#itsokaynottobeokay\", \"#sad\"]"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0-BvNrToRims"
      },
      "source": [
        "## \"#depressed\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BERTal4NwVNx"
      },
      "source": [
        "## Create a function for tweets mining\n",
        "def tweets_mining1(search_query1, num_tweets1, since_id_num1):\n",
        "  # Collect tweets using the Cursor object\n",
        "  # Each item in the iterator has various attributes that you can access to get information about each tweet\n",
        "  tweet_list1 = [tweets for tweets in tweepy.Cursor(api.search, q=search_query1, lang=\"en\", since_id=since_id_num1, \n",
        "                                                    tweet_mode='extended').items(num_tweets1)]\n",
        "  \n",
        "  # Begin scraping the tweets individually:\n",
        "  for tweet in tweet_list1[::-1]:\n",
        "    tweet_id = tweet.id # get Tweet ID result\n",
        "    created_at = tweet.created_at # get time tweet was created\n",
        "    text = tweet.full_text # retrieve full tweet text\n",
        "    location = tweet.user.location # retrieve user location\n",
        "    retweet = tweet.retweet_count # retrieve number of retweets\n",
        "    favorite = tweet.favorite_count # retrieve number of likes\n",
        "    with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_depressed_1.csv','a', newline='', encoding='utf-8') as csvFile1:\n",
        "      csv_writer1 = csv.writer(csvFile1, delimiter=',') # create an instance of csv object\n",
        "      csv_writer1.writerow([tweet_id, created_at, text, location, retweet, favorite]) # write each row"
      ],
      "execution_count": 6,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8LOXgG5xygnj"
      },
      "source": [
        "search_words1 = \"#depressed\" # Specifying exact phrase to search\n",
        "# Exclude Links, retweets, replies\n",
        "search_query1 = search_words1 + \" -filter:links AND -filter:retweets AND -filter:replies\" \n",
        "with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_depressed_1.csv', encoding='utf-8') as data:\n",
        "    latest_tweet = int(list(csv.reader(data))[-1][0]) \n",
        "tweets_mining1(search_query1, 1000, latest_tweet)"
      ],
      "execution_count": 7,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JSDTPj7Nz5Rh"
      },
      "source": [
        "df_depressed_1 = pd.read_csv(\"/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_depressed_1.csv\",\n",
        "                 names=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"])"
      ],
      "execution_count": 8,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 581
        },
        "id": "aQe7bso7VBZA",
        "outputId": "bed5b299-8399-4b86-f6d6-630085f308a8"
      },
      "source": [
        "df_depressed_1"
      ],
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1446882366945837057</td>\n",
              "      <td>2021-10-09 16:56:52</td>\n",
              "      <td>I totally need someone to hug me TIGHT and say...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1446896799860539394</td>\n",
              "      <td>2021-10-09 17:54:13</td>\n",
              "      <td>i plan on committing suicide today or tommorro...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1446912210672959491</td>\n",
              "      <td>2021-10-09 18:55:28</td>\n",
              "      <td>Exhausted! Absolutely exhausted and my day isn...</td>\n",
              "      <td>Lost 🤕</td>\n",
              "      <td>0</td>\n",
              "      <td>8</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1446931930537209856</td>\n",
              "      <td>2021-10-09 20:13:49</td>\n",
              "      <td>Im going to get Far Cry 6 and playing video ga...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1446934914453082113</td>\n",
              "      <td>2021-10-09 20:25:41</td>\n",
              "      <td>Just #depressed haven’t made money in 4 days o...</td>\n",
              "      <td>Daddy’s lap.</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1440</th>\n",
              "      <td>1459292661848883203</td>\n",
              "      <td>2021-11-12 22:50:57</td>\n",
              "      <td>it gets dark at 5 now. #depressed</td>\n",
              "      <td>Toronto, Ontario</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1441</th>\n",
              "      <td>1459295472993153030</td>\n",
              "      <td>2021-11-12 23:02:07</td>\n",
              "      <td>Ignore my tweets, if I tweet, for the next cou...</td>\n",
              "      <td>Paisley, Scotland</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1442</th>\n",
              "      <td>1459323510803759108</td>\n",
              "      <td>2021-11-13 00:53:32</td>\n",
              "      <td>how tf you a psychology major and depressed? l...</td>\n",
              "      <td>San Diego, CA</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1443</th>\n",
              "      <td>1459376207527440385</td>\n",
              "      <td>2021-11-13 04:22:56</td>\n",
              "      <td>Liquors my bestie till my flight tomorrow fml ...</td>\n",
              "      <td>Dreamville, LBC♥</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1444</th>\n",
              "      <td>1459497253698035714</td>\n",
              "      <td>2021-11-13 12:23:56</td>\n",
              "      <td>i signed up for @netflix just so i can watch b...</td>\n",
              "      <td>Washington, USA</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>1445 rows × 6 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "                 tweet.id           created_at  ... retweet favorite\n",
              "0     1446882366945837057  2021-10-09 16:56:52  ...       0        1\n",
              "1     1446896799860539394  2021-10-09 17:54:13  ...       0        1\n",
              "2     1446912210672959491  2021-10-09 18:55:28  ...       0        8\n",
              "3     1446931930537209856  2021-10-09 20:13:49  ...       0        1\n",
              "4     1446934914453082113  2021-10-09 20:25:41  ...       0        2\n",
              "...                   ...                  ...  ...     ...      ...\n",
              "1440  1459292661848883203  2021-11-12 22:50:57  ...       0        2\n",
              "1441  1459295472993153030  2021-11-12 23:02:07  ...       0        1\n",
              "1442  1459323510803759108  2021-11-13 00:53:32  ...       0        0\n",
              "1443  1459376207527440385  2021-11-13 04:22:56  ...       0        0\n",
              "1444  1459497253698035714  2021-11-13 12:23:56  ...       0        0\n",
              "\n",
              "[1445 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 9
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "gnZnQBdQ8VZL",
        "outputId": "2dc93be1-17f9-4b9d-d1d5-cab5eafdb544"
      },
      "source": [
        "## Finding unique values in each column\n",
        "for col in df_depressed_1:\n",
        "    print(\"There are \", len(df_depressed_1[col].unique()), \"unique values in \", col)"
      ],
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "There are  849 unique values in  tweet.id\n",
            "There are  849 unique values in  created_at\n",
            "There are  843 unique values in  text\n",
            "There are  383 unique values in  location\n",
            "There are  7 unique values in  retweet\n",
            "There are  25 unique values in  favorite\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "jVSywSxSvYbS"
      },
      "source": [
        "### Anxiety and suicide "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "1UWM-o41vd6Z"
      },
      "source": [
        "## Create a function for tweets mining\n",
        "def tweets_mining2(search_query2, num_tweets2, since_id_num2):\n",
        "  # Collect tweets using the Cursor object\n",
        "  # Each item in the iterator has various attributes that you can access to get information about each tweet\n",
        "  tweet_list2 = [tweets for tweets in tweepy.Cursor(api.search, q=search_query2, lang=\"en\", since_id=since_id_num2, \n",
        "                                                    tweet_mode='extended').items(num_tweets2)]\n",
        "  \n",
        "  # Begin scraping the tweets individually:\n",
        "  for tweet in tweet_list2[::-1]:\n",
        "    tweet_id = tweet.id # get Tweet ID result\n",
        "    created_at = tweet.created_at # get time tweet was created\n",
        "    text = tweet.full_text # retrieve full tweet text\n",
        "    location = tweet.user.location # retrieve user location\n",
        "    retweet = tweet.retweet_count # retrieve number of retweets\n",
        "    favorite = tweet.favorite_count # retrieve number of likes\n",
        "    with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_anxiety_1.csv','a', newline='', encoding='utf-8') as csvFile2:\n",
        "      csv_writer2 = csv.writer(csvFile2, delimiter=',') # create an instance of csv object\n",
        "      csv_writer2.writerow([tweet_id, created_at, text, location, retweet, favorite]) # write each row"
      ],
      "execution_count": 11,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "4WS3HYJ_yUPe"
      },
      "source": [
        "search_words2 = \"#anxiety\" # Specifying exact phrase to search\n",
        "# Exclude Links, retweets, replies\n",
        "search_query2 = search_words2 + \" -filter:links AND -filter:retweets AND -filter:replies\"\n",
        "with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_anxiety_1.csv', encoding='utf-8') as data:\n",
        "    latest_tweet = int(list(csv.reader(data))[-1][0]) \n",
        "tweets_mining2(search_query2, 2000, latest_tweet)"
      ],
      "execution_count": 12,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "mMnPf-UoD1gA"
      },
      "source": [
        "df_anxiety_1 = pd.read_csv(\"/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_anxiety_1.csv\",\n",
        "                 names=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"])"
      ],
      "execution_count": 13,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 581
        },
        "id": "SyvsN8-3D73N",
        "outputId": "d139df05-638a-4a91-e94c-e7560db53069"
      },
      "source": [
        "df_anxiety_1"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1447067749654614019</td>\n",
              "      <td>2021-10-10 05:13:31</td>\n",
              "      <td>I  can't wait to get the hell out. so I'll jus...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1447069714379857927</td>\n",
              "      <td>2021-10-10 05:21:19</td>\n",
              "      <td>Morning. All people except me sleeping. @Billy...</td>\n",
              "      <td>Queenie's Castle,Yate, S Glos</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1447072203388985346</td>\n",
              "      <td>2021-10-10 05:31:13</td>\n",
              "      <td>On #WorldMentalHealthDay, a big shoutout to my...</td>\n",
              "      <td>Bengaluru/Muscat/Palakad/Kochi</td>\n",
              "      <td>0</td>\n",
              "      <td>9</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1447072334825754626</td>\n",
              "      <td>2021-10-10 05:31:44</td>\n",
              "      <td>I hate having anxiety about doing stuff that I...</td>\n",
              "      <td>Utah, USA</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1447074986531848192</td>\n",
              "      <td>2021-10-10 05:42:16</td>\n",
              "      <td>I am not scared of my ADHD, depression and anx...</td>\n",
              "      <td>Wollongong, New South Wales</td>\n",
              "      <td>2</td>\n",
              "      <td>11</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6867</th>\n",
              "      <td>1459224031777939460</td>\n",
              "      <td>2021-11-12 18:18:14</td>\n",
              "      <td>It’s amazing how everyone runs to me as the su...</td>\n",
              "      <td>Pennsylvania, USA</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6868</th>\n",
              "      <td>1459224808512704516</td>\n",
              "      <td>2021-11-12 18:21:20</td>\n",
              "      <td>Any suggestions on settling the stomach after ...</td>\n",
              "      <td>Everywhere, Anywhere</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6869</th>\n",
              "      <td>1459228047278751747</td>\n",
              "      <td>2021-11-12 18:34:12</td>\n",
              "      <td>Gotta love that superpowered #anxiety taking h...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6870</th>\n",
              "      <td>1459229518128893952</td>\n",
              "      <td>2021-11-12 18:40:02</td>\n",
              "      <td>Growth nor healing is linear. Sometimes you ma...</td>\n",
              "      <td>London</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6871</th>\n",
              "      <td>1459230527358222337</td>\n",
              "      <td>2021-11-12 18:44:03</td>\n",
              "      <td>Just read on a YouTube comment how mentally il...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>6872 rows × 6 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "                 tweet.id           created_at  ... retweet favorite\n",
              "0     1447067749654614019  2021-10-10 05:13:31  ...       0        0\n",
              "1     1447069714379857927  2021-10-10 05:21:19  ...       0        1\n",
              "2     1447072203388985346  2021-10-10 05:31:13  ...       0        9\n",
              "3     1447072334825754626  2021-10-10 05:31:44  ...       0        0\n",
              "4     1447074986531848192  2021-10-10 05:42:16  ...       2       11\n",
              "...                   ...                  ...  ...     ...      ...\n",
              "6867  1459224031777939460  2021-11-12 18:18:14  ...       0        0\n",
              "6868  1459224808512704516  2021-11-12 18:21:20  ...       0        0\n",
              "6869  1459228047278751747  2021-11-12 18:34:12  ...       0        0\n",
              "6870  1459229518128893952  2021-11-12 18:40:02  ...       0        0\n",
              "6871  1459230527358222337  2021-11-12 18:44:03  ...       0        0\n",
              "\n",
              "[6872 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 14
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "ygvC0l-C9NXp",
        "outputId": "cef49691-326a-43d4-a7d5-28725aafc5b5"
      },
      "source": [
        "## Finding unique values in each column\n",
        "for col in df_anxiety_1:\n",
        "    print(\"There are \", len(df_anxiety_1[col].unique()), \"unique values in \", col)"
      ],
      "execution_count": 15,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "There are  4738 unique values in  tweet.id\n",
            "There are  4733 unique values in  created_at\n",
            "There are  4342 unique values in  text\n",
            "There are  1381 unique values in  location\n",
            "There are  33 unique values in  retweet\n",
            "There are  80 unique values in  favorite\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "iSbEvJo0CVBh"
      },
      "source": [
        "## \"#Suicide\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ofqzhBcR1bj-"
      },
      "source": [
        "## Create a function for tweets mining\n",
        "def tweets_mining3(search_query3, num_tweets3, since_id_num3):\n",
        "  # Collect tweets using the Cursor object\n",
        "  # Each item in the iterator has various attributes that you can access to get information about each tweet\n",
        "  tweet_list3 = [tweets for tweets in tweepy.Cursor(api.search, q=search_query3, lang=\"en\", since_id=since_id_num3, \n",
        "                                                    tweet_mode='extended').items(num_tweets3)]\n",
        "  \n",
        "  # Begin scraping the tweets individually:\n",
        "  for tweet in tweet_list3[::-1]:\n",
        "    tweet_id = tweet.id # get Tweet ID result\n",
        "    created_at = tweet.created_at # get time tweet was created\n",
        "    text = tweet.full_text # retrieve full tweet text\n",
        "    location = tweet.user.location # retrieve user location\n",
        "    retweet = tweet.retweet_count # retrieve number of retweets\n",
        "    favorite = tweet.favorite_count # retrieve number of likes\n",
        "    with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_suicide_1.csv','a', newline='', encoding='utf-8') as csvFile3:\n",
        "      csv_writer3 = csv.writer(csvFile3, delimiter=',') # create an instance of csv object\n",
        "      csv_writer3.writerow([tweet_id, created_at, text, location, retweet, favorite]) # write each row"
      ],
      "execution_count": 10,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "_wIXzt57Cn3e"
      },
      "source": [
        "search_words3 = \"#suicide\" # Specifying exact phrase to search\n",
        "# Exclude Links, retweets, replies\n",
        "search_query3 = search_words3 + \" -filter:links AND -filter:retweets AND -filter:replies\" \n",
        "with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_suicide_1.csv', encoding='utf-8') as data:\n",
        "    latest_tweet = int(list(csv.reader(data))[-1][0]) \n",
        "tweets_mining3(search_query3, 10000, latest_tweet)"
      ],
      "execution_count": 11,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "XkfhTVodENiy"
      },
      "source": [
        "df_suicide_1 = pd.read_csv(\"/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_suicide_1.csv\",\n",
        "                 names=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"])"
      ],
      "execution_count": 12,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 581
        },
        "id": "8HAqIISVEXFy",
        "outputId": "0667d586-2e25-4690-95b4-a86f748e9eae"
      },
      "source": [
        "df_suicide_1"
      ],
      "execution_count": 13,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1447381474034999296</td>\n",
              "      <td>2021-10-11 02:00:09</td>\n",
              "      <td>#suicide is the strong belief that no matter h...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1447439429409415172</td>\n",
              "      <td>2021-10-11 05:50:26</td>\n",
              "      <td>\"suicide\"\\nHollowness enough\\nSilence enough\\n...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>2</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1447444376464998400</td>\n",
              "      <td>2021-10-11 06:10:06</td>\n",
              "      <td>Every year passes but the pain remains the sam...</td>\n",
              "      <td>India</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1447445469467131906</td>\n",
              "      <td>2021-10-11 06:14:26</td>\n",
              "      <td>Have I told you how much I hate my life😂😂😁 #su...</td>\n",
              "      <td>Ohio, USA</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1447461306295013377</td>\n",
              "      <td>2021-10-11 07:17:22</td>\n",
              "      <td>The man responsible for the #CDC policies that...</td>\n",
              "      <td>United States</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>713</th>\n",
              "      <td>1459446304577363971</td>\n",
              "      <td>2021-11-13 09:01:28</td>\n",
              "      <td>Someone wanted me to tell you. You're beautifu...</td>\n",
              "      <td>D(1) Florida</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>714</th>\n",
              "      <td>1459454059975352320</td>\n",
              "      <td>2021-11-13 09:32:17</td>\n",
              "      <td>It's a regular thing🙂💔\\n#Coimbatore #suicide #...</td>\n",
              "      <td>Tiruppur, India</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>715</th>\n",
              "      <td>1459454073644765185</td>\n",
              "      <td>2021-11-13 09:32:21</td>\n",
              "      <td>#Suicide is not as bad as people make it \\n\\nB...</td>\n",
              "      <td>The Chisolm Trail</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>716</th>\n",
              "      <td>1459495548373934081</td>\n",
              "      <td>2021-11-13 12:17:09</td>\n",
              "      <td>Just Uploaded My Review Of Dear Evan Hansen To...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>717</th>\n",
              "      <td>1459525084180267027</td>\n",
              "      <td>2021-11-13 14:14:31</td>\n",
              "      <td>On #WorldKindnessDay we would just like to say...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>1</td>\n",
              "      <td>5</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>718 rows × 6 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "                tweet.id           created_at  ... retweet favorite\n",
              "0    1447381474034999296  2021-10-11 02:00:09  ...       0        0\n",
              "1    1447439429409415172  2021-10-11 05:50:26  ...       2        2\n",
              "2    1447444376464998400  2021-10-11 06:10:06  ...       0        0\n",
              "3    1447445469467131906  2021-10-11 06:14:26  ...       0        1\n",
              "4    1447461306295013377  2021-10-11 07:17:22  ...       1        2\n",
              "..                   ...                  ...  ...     ...      ...\n",
              "713  1459446304577363971  2021-11-13 09:01:28  ...       0        0\n",
              "714  1459454059975352320  2021-11-13 09:32:17  ...       0        3\n",
              "715  1459454073644765185  2021-11-13 09:32:21  ...       0        0\n",
              "716  1459495548373934081  2021-11-13 12:17:09  ...       0        0\n",
              "717  1459525084180267027  2021-11-13 14:14:31  ...       1        5\n",
              "\n",
              "[718 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 13
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ZilsrGx9Ex2i"
      },
      "source": [
        "## \"#hopelessness\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "mqFLOv-AE5Lw"
      },
      "source": [
        "## Create a function for tweets mining\n",
        "def tweets_mining4(search_query4, num_tweets4, since_id_num4):\n",
        "  # Collect tweets using the Cursor object\n",
        "  # Each item in the iterator has various attributes that you can access to get information about each tweet\n",
        "  tweet_list4 = [tweets for tweets in tweepy.Cursor(api.search, q=search_query4, lang=\"en\", since_id=since_id_num4, \n",
        "                                                    tweet_mode='extended').items(num_tweets4)]\n",
        "  \n",
        "  # Begin scraping the tweets individually:\n",
        "  for tweet in tweet_list4[::-1]:\n",
        "    tweet_id = tweet.id # get Tweet ID result\n",
        "    created_at = tweet.created_at # get time tweet was created\n",
        "    text = tweet.full_text # retrieve full tweet text\n",
        "    location = tweet.user.location # retrieve user location\n",
        "    retweet = tweet.retweet_count # retrieve number of retweets\n",
        "    favorite = tweet.favorite_count # retrieve number of likes\n",
        "    with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_hopeless_1.csv','a', newline='', encoding='utf-8') as csvFile4:\n",
        "      csv_writer4 = csv.writer(csvFile4, delimiter=',') # create an instance of csv object\n",
        "      csv_writer4.writerow([tweet_id, created_at, text, location, retweet, favorite]) # write each row"
      ],
      "execution_count": 14,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7Pf9avomE-G6"
      },
      "source": [
        "search_words4 = \"#hopelessness\" # Specifying exact phrase to search\n",
        "# Exclude Links, retweets, replies\n",
        "search_query4 = search_words4 + \" -filter:links AND -filter:retweets AND -filter:replies\"\n",
        "with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_hopeless_1.csv', encoding='utf-8') as data:\n",
        "    latest_tweet = int(list(csv.reader(data))[-1][0]) \n",
        "tweets_mining4(search_query4, 10000, latest_tweet)"
      ],
      "execution_count": 15,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "pSauv_5jFAzX"
      },
      "source": [
        "df_hopeless_1 = pd.read_csv(\"/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_hopeless_1.csv\",\n",
        "                 names=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"])"
      ],
      "execution_count": 16,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "jFjXgpXDFwn1",
        "outputId": "a063c672-3333-4e3b-c71e-c3329270854e"
      },
      "source": [
        "df_hopeless_1"
      ],
      "execution_count": 17,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1447537898572574730</td>\n",
              "      <td>2021-10-11 12:21:43</td>\n",
              "      <td>Open discussion. Between the Transfer Portal a...</td>\n",
              "      <td>Cheyenne Wyoming</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1447540582490988553</td>\n",
              "      <td>2021-10-11 12:32:23</td>\n",
              "      <td>Plenty of things are changing in my life and t...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1447807717859491842</td>\n",
              "      <td>2021-10-12 06:13:53</td>\n",
              "      <td>I feel a little hopeless. Anyone else? #hopele...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1448076026219692033</td>\n",
              "      <td>2021-10-13 00:00:03</td>\n",
              "      <td>Which is more healthy? Hope, or hopelessness? ...</td>\n",
              "      <td>Denver, CO</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1448382047375040513</td>\n",
              "      <td>2021-10-13 20:16:04</td>\n",
              "      <td>So someone tell me how do I get over #HOPELESS...</td>\n",
              "      <td>Portland Or .</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>5</th>\n",
              "      <td>1448595145138622464</td>\n",
              "      <td>2021-10-14 10:22:50</td>\n",
              "      <td>No parent deserves to experience the Indian le...</td>\n",
              "      <td>Bombay, Dubai</td>\n",
              "      <td>1</td>\n",
              "      <td>4</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6</th>\n",
              "      <td>1448843909841313793</td>\n",
              "      <td>2021-10-15 02:51:20</td>\n",
              "      <td>Being in a #union also looks a lot like being ...</td>\n",
              "      <td>Alberta, Canada</td>\n",
              "      <td>7</td>\n",
              "      <td>17</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>7</th>\n",
              "      <td>1449848070783524864</td>\n",
              "      <td>2021-10-17 21:21:31</td>\n",
              "      <td>I am so glad that @GreysABC is tackling the hu...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>8</th>\n",
              "      <td>1447537898572574730</td>\n",
              "      <td>2021-10-11 12:21:43</td>\n",
              "      <td>Open discussion. Between the Transfer Portal a...</td>\n",
              "      <td>Cheyenne Wyoming</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>9</th>\n",
              "      <td>1447540582490988553</td>\n",
              "      <td>2021-10-11 12:32:23</td>\n",
              "      <td>Plenty of things are changing in my life and t...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>10</th>\n",
              "      <td>1447807717859491842</td>\n",
              "      <td>2021-10-12 06:13:53</td>\n",
              "      <td>I feel a little hopeless. Anyone else? #hopele...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>11</th>\n",
              "      <td>1448076026219692033</td>\n",
              "      <td>2021-10-13 00:00:03</td>\n",
              "      <td>Which is more healthy? Hope, or hopelessness? ...</td>\n",
              "      <td>Denver, CO</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>12</th>\n",
              "      <td>1448382047375040513</td>\n",
              "      <td>2021-10-13 20:16:04</td>\n",
              "      <td>So someone tell me how do I get over #HOPELESS...</td>\n",
              "      <td>Portland Or .</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>13</th>\n",
              "      <td>1448595145138622464</td>\n",
              "      <td>2021-10-14 10:22:50</td>\n",
              "      <td>No parent deserves to experience the Indian le...</td>\n",
              "      <td>Bombay, Dubai</td>\n",
              "      <td>1</td>\n",
              "      <td>4</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>14</th>\n",
              "      <td>1448843909841313793</td>\n",
              "      <td>2021-10-15 02:51:20</td>\n",
              "      <td>Being in a #union also looks a lot like being ...</td>\n",
              "      <td>Alberta, Canada</td>\n",
              "      <td>7</td>\n",
              "      <td>17</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>15</th>\n",
              "      <td>1449848070783524864</td>\n",
              "      <td>2021-10-17 21:21:31</td>\n",
              "      <td>I am so glad that @GreysABC is tackling the hu...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>16</th>\n",
              "      <td>1447537898572574730</td>\n",
              "      <td>2021-10-11 12:21:43</td>\n",
              "      <td>Open discussion. Between the Transfer Portal a...</td>\n",
              "      <td>Cheyenne Wyoming</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>17</th>\n",
              "      <td>1447540582490988553</td>\n",
              "      <td>2021-10-11 12:32:23</td>\n",
              "      <td>Plenty of things are changing in my life and t...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>18</th>\n",
              "      <td>1447807717859491842</td>\n",
              "      <td>2021-10-12 06:13:53</td>\n",
              "      <td>I feel a little hopeless. Anyone else? #hopele...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>19</th>\n",
              "      <td>1448076026219692033</td>\n",
              "      <td>2021-10-13 00:00:03</td>\n",
              "      <td>Which is more healthy? Hope, or hopelessness? ...</td>\n",
              "      <td>Denver, CO</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>20</th>\n",
              "      <td>1448382047375040513</td>\n",
              "      <td>2021-10-13 20:16:04</td>\n",
              "      <td>So someone tell me how do I get over #HOPELESS...</td>\n",
              "      <td>Portland Or .</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>21</th>\n",
              "      <td>1448595145138622464</td>\n",
              "      <td>2021-10-14 10:22:50</td>\n",
              "      <td>No parent deserves to experience the Indian le...</td>\n",
              "      <td>Bombay, Dubai</td>\n",
              "      <td>1</td>\n",
              "      <td>4</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>22</th>\n",
              "      <td>1448843909841313793</td>\n",
              "      <td>2021-10-15 02:51:20</td>\n",
              "      <td>Being in a #union also looks a lot like being ...</td>\n",
              "      <td>Alberta, Canada</td>\n",
              "      <td>7</td>\n",
              "      <td>17</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>23</th>\n",
              "      <td>1449848070783524864</td>\n",
              "      <td>2021-10-17 21:21:31</td>\n",
              "      <td>I am so glad that @GreysABC is tackling the hu...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>24</th>\n",
              "      <td>1451858330591318022</td>\n",
              "      <td>2021-10-23 10:29:34</td>\n",
              "      <td>If you know someone who’s depressed please res...</td>\n",
              "      <td>Rwanda</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>25</th>\n",
              "      <td>1453499016394723330</td>\n",
              "      <td>2021-10-27 23:09:04</td>\n",
              "      <td>A #grateful #heart will #SeeGod. You will find...</td>\n",
              "      <td>Berlin, NJ</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>26</th>\n",
              "      <td>1453738324598865920</td>\n",
              "      <td>2021-10-28 15:00:00</td>\n",
              "      <td>“Our world today so desperately hungers for ho...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>27</th>\n",
              "      <td>1453745900996726785</td>\n",
              "      <td>2021-10-28 15:30:06</td>\n",
              "      <td>Depression is a bitch that is difficult for me...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>28</th>\n",
              "      <td>1454441137951821824</td>\n",
              "      <td>2021-10-30 13:32:44</td>\n",
              "      <td>Add to this list #whatsincreased \\n#petrol\\n#d...</td>\n",
              "      <td>New Delhi, India</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>29</th>\n",
              "      <td>1456980506160025604</td>\n",
              "      <td>2021-11-06 13:43:16</td>\n",
              "      <td>\"Hopelessness has surprised me with patience.\"...</td>\n",
              "      <td>Planet Earth</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>30</th>\n",
              "      <td>1457005145510797315</td>\n",
              "      <td>2021-11-06 15:21:11</td>\n",
              "      <td>“Go if you have to, but remember, don’t come b...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>31</th>\n",
              "      <td>1457192619184902147</td>\n",
              "      <td>2021-11-07 03:46:08</td>\n",
              "      <td>Hey @Headspace, I need to believe in something...</td>\n",
              "      <td>Santo Mondongo</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>32</th>\n",
              "      <td>1458953923151212548</td>\n",
              "      <td>2021-11-12 00:24:55</td>\n",
              "      <td>2 years ago I attempted #suicide to escape #do...</td>\n",
              "      <td>Carpentersville, IL</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>33</th>\n",
              "      <td>1459449269140787202</td>\n",
              "      <td>2021-11-13 09:13:15</td>\n",
              "      <td>WARNING: Being deprived of God’s joy will lead...</td>\n",
              "      <td>United States</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "               tweet.id           created_at  ... retweet favorite\n",
              "0   1447537898572574730  2021-10-11 12:21:43  ...       0        0\n",
              "1   1447540582490988553  2021-10-11 12:32:23  ...       0        0\n",
              "2   1447807717859491842  2021-10-12 06:13:53  ...       0        0\n",
              "3   1448076026219692033  2021-10-13 00:00:03  ...       0        0\n",
              "4   1448382047375040513  2021-10-13 20:16:04  ...       0        2\n",
              "5   1448595145138622464  2021-10-14 10:22:50  ...       1        4\n",
              "6   1448843909841313793  2021-10-15 02:51:20  ...       7       17\n",
              "7   1449848070783524864  2021-10-17 21:21:31  ...       0        1\n",
              "8   1447537898572574730  2021-10-11 12:21:43  ...       0        0\n",
              "9   1447540582490988553  2021-10-11 12:32:23  ...       0        0\n",
              "10  1447807717859491842  2021-10-12 06:13:53  ...       0        0\n",
              "11  1448076026219692033  2021-10-13 00:00:03  ...       0        0\n",
              "12  1448382047375040513  2021-10-13 20:16:04  ...       0        2\n",
              "13  1448595145138622464  2021-10-14 10:22:50  ...       1        4\n",
              "14  1448843909841313793  2021-10-15 02:51:20  ...       7       17\n",
              "15  1449848070783524864  2021-10-17 21:21:31  ...       0        1\n",
              "16  1447537898572574730  2021-10-11 12:21:43  ...       0        0\n",
              "17  1447540582490988553  2021-10-11 12:32:23  ...       0        0\n",
              "18  1447807717859491842  2021-10-12 06:13:53  ...       0        0\n",
              "19  1448076026219692033  2021-10-13 00:00:03  ...       0        0\n",
              "20  1448382047375040513  2021-10-13 20:16:04  ...       0        2\n",
              "21  1448595145138622464  2021-10-14 10:22:50  ...       1        4\n",
              "22  1448843909841313793  2021-10-15 02:51:20  ...       7       17\n",
              "23  1449848070783524864  2021-10-17 21:21:31  ...       1        2\n",
              "24  1451858330591318022  2021-10-23 10:29:34  ...       0        1\n",
              "25  1453499016394723330  2021-10-27 23:09:04  ...       0        1\n",
              "26  1453738324598865920  2021-10-28 15:00:00  ...       0        0\n",
              "27  1453745900996726785  2021-10-28 15:30:06  ...       0        3\n",
              "28  1454441137951821824  2021-10-30 13:32:44  ...       0        0\n",
              "29  1456980506160025604  2021-11-06 13:43:16  ...       0        0\n",
              "30  1457005145510797315  2021-11-06 15:21:11  ...       0        0\n",
              "31  1457192619184902147  2021-11-07 03:46:08  ...       0        0\n",
              "32  1458953923151212548  2021-11-12 00:24:55  ...       0        2\n",
              "33  1459449269140787202  2021-11-13 09:13:15  ...       0        0\n",
              "\n",
              "[34 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 17
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "zsX2-S8vGGh8"
      },
      "source": [
        "## \"#mentalhealth\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "gdvSCV-oGOP8"
      },
      "source": [
        "## Create a function for tweets mining\n",
        "def tweets_mining5(search_query5, num_tweets5, since_id_num5):\n",
        "  # Collect tweets using the Cursor object\n",
        "  # Each item in the iterator has various attributes that you can access to get information about each tweet\n",
        "  tweet_list5 = [tweets for tweets in tweepy.Cursor(api.search, q=search_query5, lang=\"en\", since_id=since_id_num5, \n",
        "                                                    tweet_mode='extended').items(num_tweets5)]\n",
        "  \n",
        "  # Begin scraping the tweets individually:\n",
        "  for tweet in tweet_list5[::-1]:\n",
        "    tweet_id = tweet.id # get Tweet ID result\n",
        "    created_at = tweet.created_at # get time tweet was created\n",
        "    text = tweet.full_text # retrieve full tweet text\n",
        "    location = tweet.user.location # retrieve user location\n",
        "    retweet = tweet.retweet_count # retrieve number of retweets\n",
        "    favorite = tweet.favorite_count # retrieve number of likes\n",
        "    with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_mentalhealth_1.csv','a', newline='', encoding='utf-8') as csvFile5:\n",
        "      csv_writer5 = csv.writer(csvFile5, delimiter=',') # create an instance of csv object\n",
        "      csv_writer5.writerow([tweet_id, created_at, text, location, retweet, favorite]) # write each row"
      ],
      "execution_count": 18,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Euoe88tsGdkc"
      },
      "source": [
        "search_words5 = \"#mentalhealth\" # Specifying exact phrase to search\n",
        "# Exclude Links, retweets, replies\n",
        "search_query5 = search_words5 + \" -filter:links AND -filter:retweets AND -filter:replies\" \n",
        "with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_mentalhealth_1.csv', encoding='utf-8') as data:\n",
        "    latest_tweet = int(list(csv.reader(data))[-1][0])\n",
        "tweets_mining5(search_query5, 1000, latest_tweet)"
      ],
      "execution_count": 19,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "s8rbK0pOGu80"
      },
      "source": [
        "df_mentalhealth_1 = pd.read_csv(\"/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_mentalhealth_1.csv\",\n",
        "                 names=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"])"
      ],
      "execution_count": 20,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 581
        },
        "id": "CpmrexYEH9ii",
        "outputId": "0b26846b-b32d-44ea-8612-4cfb551bb444"
      },
      "source": [
        "df_mentalhealth_1"
      ],
      "execution_count": 21,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1449685870945185792</td>\n",
              "      <td>2021-10-17 10:37:00</td>\n",
              "      <td>Sunday's goals. \\n1. Take meds\\n2. Drink 3 lit...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1449686119658840065</td>\n",
              "      <td>2021-10-17 10:37:59</td>\n",
              "      <td>\"????\"  #Mentalhealth\\n\\ni'm tired of fighting...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1449686255185321986</td>\n",
              "      <td>2021-10-17 10:38:31</td>\n",
              "      <td>Surrounded by people but feeling so alone 😔 \\n...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1449686716168671232</td>\n",
              "      <td>2021-10-17 10:40:21</td>\n",
              "      <td>I understand my dv worker has emergencies but ...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1449687397776592898</td>\n",
              "      <td>2021-10-17 10:43:04</td>\n",
              "      <td>Struggling to get out of bed and do things tha...</td>\n",
              "      <td>England, United Kingdom</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6592</th>\n",
              "      <td>1459531596009283600</td>\n",
              "      <td>2021-11-13 14:40:23</td>\n",
              "      <td>Let’s make good choices today friends!!! ❤️ #R...</td>\n",
              "      <td>Florida, USA</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6593</th>\n",
              "      <td>1459532754387976200</td>\n",
              "      <td>2021-11-13 14:45:00</td>\n",
              "      <td>Oh it’s a dark joke when I say I wanna bedazzl...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6594</th>\n",
              "      <td>1459532763942604800</td>\n",
              "      <td>2021-11-13 14:45:02</td>\n",
              "      <td>I discovered today that clothes shopping is a ...</td>\n",
              "      <td>England, United Kingdom</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6595</th>\n",
              "      <td>1459532906074935304</td>\n",
              "      <td>2021-11-13 14:45:36</td>\n",
              "      <td>We composed a tweet thread about our college's...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>6596</th>\n",
              "      <td>1459533316428754950</td>\n",
              "      <td>2021-11-13 14:47:14</td>\n",
              "      <td>feels awkward at 1st but don’t know how i feel...</td>\n",
              "      <td>Anaheim, CA</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>6597 rows × 6 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "                 tweet.id           created_at  ... retweet favorite\n",
              "0     1449685870945185792  2021-10-17 10:37:00  ...       0        1\n",
              "1     1449686119658840065  2021-10-17 10:37:59  ...       0        0\n",
              "2     1449686255185321986  2021-10-17 10:38:31  ...       0        1\n",
              "3     1449686716168671232  2021-10-17 10:40:21  ...       0        0\n",
              "4     1449687397776592898  2021-10-17 10:43:04  ...       0        0\n",
              "...                   ...                  ...  ...     ...      ...\n",
              "6592  1459531596009283600  2021-11-13 14:40:23  ...       0        1\n",
              "6593  1459532754387976200  2021-11-13 14:45:00  ...       0        1\n",
              "6594  1459532763942604800  2021-11-13 14:45:02  ...       0        1\n",
              "6595  1459532906074935304  2021-11-13 14:45:36  ...       0        1\n",
              "6596  1459533316428754950  2021-11-13 14:47:14  ...       0        1\n",
              "\n",
              "[6597 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 21
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Jwcc9Bwdx0ie"
      },
      "source": [
        "## \"#loneliness\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tfu8ca0Wx1m9"
      },
      "source": [
        "## Create a function for tweets mining\n",
        "def tweets_mining6(search_query6, num_tweets6, since_id_num6):\n",
        "  # Collect tweets using the Cursor object\n",
        "  # Each item in the iterator has various attributes that you can access to get information about each tweet\n",
        "  tweet_list6 = [tweets for tweets in tweepy.Cursor(api.search, q=search_query6, lang=\"en\", since_id=since_id_num6, \n",
        "                                                    tweet_mode='extended').items(num_tweets6)]\n",
        "  \n",
        "  # Begin scraping the tweets individually:\n",
        "  for tweet in tweet_list6[::-1]:\n",
        "    tweet_id = tweet.id # get Tweet ID result\n",
        "    created_at = tweet.created_at # get time tweet was created\n",
        "    text = tweet.full_text # retrieve full tweet text\n",
        "    location = tweet.user.location # retrieve user location\n",
        "    retweet = tweet.retweet_count # retrieve number of retweets\n",
        "    favorite = tweet.favorite_count # retrieve number of likes\n",
        "    with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_loneliness_1.csv','a', newline='', encoding='utf-8') as csvFile6:\n",
        "      csv_writer6 = csv.writer(csvFile6, delimiter=',') # create an instance of csv object\n",
        "      csv_writer6.writerow([tweet_id, created_at, text, location, retweet, favorite]) # write each row"
      ],
      "execution_count": 22,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "veyW6kE7z5A0"
      },
      "source": [
        "search_words6 = \"#loneliness\" # Specifying exact phrase to search\n",
        "# Exclude Links, retweets, replies\n",
        "search_query6 = search_words6 + \" -filter:links AND -filter:retweets AND -filter:replies\" \n",
        "with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_loneliness_1.csv', encoding='utf-8') as data:\n",
        "    latest_tweet = int(list(csv.reader(data))[-1][0])\n",
        "tweets_mining6(search_query6, 10000, latest_tweet)"
      ],
      "execution_count": 23,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "bggxtMrn0EGM"
      },
      "source": [
        "df_loneliness_1 = pd.read_csv(\"/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_loneliness_1.csv\",\n",
        "                 names=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"])"
      ],
      "execution_count": 24,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 581
        },
        "id": "SlXTyO6d0KrH",
        "outputId": "a8a7127b-34e5-437e-effd-a1364ff5bad5"
      },
      "source": [
        "df_loneliness_1"
      ],
      "execution_count": 25,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1447444376464998400</td>\n",
              "      <td>2021-10-11 06:10:06</td>\n",
              "      <td>Every year passes but the pain remains the sam...</td>\n",
              "      <td>India</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1447517473679441921</td>\n",
              "      <td>2021-10-11 11:00:33</td>\n",
              "      <td>In this life, I can't expect things to be in m...</td>\n",
              "      <td>Davao Region</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1447540227422162949</td>\n",
              "      <td>2021-10-11 12:30:58</td>\n",
              "      <td>holidays can bring on a sense of loss - of fam...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1447564113928863744</td>\n",
              "      <td>2021-10-11 14:05:53</td>\n",
              "      <td>Must be good to have someone by your side. #Lo...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1447599325304000515</td>\n",
              "      <td>2021-10-11 16:25:48</td>\n",
              "      <td>#Artists without an air of #loneliness , are #...</td>\n",
              "      <td>Sulaimanyah, Kurdistan</td>\n",
              "      <td>0</td>\n",
              "      <td>5</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>306</th>\n",
              "      <td>1459371193283362820</td>\n",
              "      <td>2021-11-13 04:03:00</td>\n",
              "      <td>I want someone who loves to take nighttime dri...</td>\n",
              "      <td>North Carolina, USA</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>307</th>\n",
              "      <td>1459473286836989959</td>\n",
              "      <td>2021-11-13 10:48:41</td>\n",
              "      <td>I have apparently reached the point of #autist...</td>\n",
              "      <td>South West, England</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>308</th>\n",
              "      <td>1459491234473553921</td>\n",
              "      <td>2021-11-13 12:00:00</td>\n",
              "      <td>Give us a call. Need any advice with #covid19 ...</td>\n",
              "      <td>Dublin City, Ireland</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>309</th>\n",
              "      <td>1459495762908401664</td>\n",
              "      <td>2021-11-13 12:18:00</td>\n",
              "      <td>fob lyrics trying so hard to be someone you’re...</td>\n",
              "      <td>she/they • 18 • scorpio</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>310</th>\n",
              "      <td>1459513880527441920</td>\n",
              "      <td>2021-11-13 13:30:00</td>\n",
              "      <td>Give us a call. Need any advice with #covid19 ...</td>\n",
              "      <td>Dublin City, Ireland</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>311 rows × 6 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "                tweet.id           created_at  ... retweet favorite\n",
              "0    1447444376464998400  2021-10-11 06:10:06  ...       0        0\n",
              "1    1447517473679441921  2021-10-11 11:00:33  ...       0        0\n",
              "2    1447540227422162949  2021-10-11 12:30:58  ...       0        0\n",
              "3    1447564113928863744  2021-10-11 14:05:53  ...       0        0\n",
              "4    1447599325304000515  2021-10-11 16:25:48  ...       0        5\n",
              "..                   ...                  ...  ...     ...      ...\n",
              "306  1459371193283362820  2021-11-13 04:03:00  ...       0        0\n",
              "307  1459473286836989959  2021-11-13 10:48:41  ...       0        1\n",
              "308  1459491234473553921  2021-11-13 12:00:00  ...       1        1\n",
              "309  1459495762908401664  2021-11-13 12:18:00  ...       0        1\n",
              "310  1459513880527441920  2021-11-13 13:30:00  ...       0        0\n",
              "\n",
              "[311 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 25
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "QnHoDxZ70SnD"
      },
      "source": [
        "## \"#itsokaynottobeokay\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "WtQHpt-c0Te1"
      },
      "source": [
        "## Create a function for tweets mining\n",
        "def tweets_mining7(search_query7, num_tweets7, since_id_num7):\n",
        "  # Collect tweets using the Cursor object\n",
        "  # Each item in the iterator has various attributes that you can access to get information about each tweet\n",
        "  tweet_list7 = [tweets for tweets in tweepy.Cursor(api.search, q=search_query7, lang=\"en\", since_id=since_id_num7, \n",
        "                                                    tweet_mode='extended').items(num_tweets7)]\n",
        "  \n",
        "  # Begin scraping the tweets individually:\n",
        "  for tweet in tweet_list7[::-1]:\n",
        "    tweet_id = tweet.id # get Tweet ID result\n",
        "    created_at = tweet.created_at # get time tweet was created\n",
        "    text = tweet.full_text # retrieve full tweet text\n",
        "    location = tweet.user.location # retrieve user location\n",
        "    retweet = tweet.retweet_count # retrieve number of retweets\n",
        "    favorite = tweet.favorite_count # retrieve number of likes\n",
        "    with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_itsoknottobeok_1 copy.csv','a', newline='', encoding='utf-8') as csvFile7:\n",
        "      csv_writer7 = csv.writer(csvFile7, delimiter=',') # create an instance of csv object\n",
        "      csv_writer7.writerow([tweet_id, created_at, text, location, retweet, favorite]) # write each row"
      ],
      "execution_count": 26,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "TP-dBQTL1vkD"
      },
      "source": [
        "search_words7 = \"#itsokaynottobeokay\" # Specifying exact phrase to search\n",
        "# Exclude Links, retweets, replies\n",
        "search_query7 = search_words7 + \" -filter:links AND -filter:retweets AND -filter:replies\"\n",
        "with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_itsoknottobeok_1 copy.csv', encoding='utf-8') as data:\n",
        "    latest_tweet = int(list(csv.reader(data))[-1][0]) \n",
        "tweets_mining7(search_query7, 2000, latest_tweet)"
      ],
      "execution_count": 27,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "IEyjMy_B2hc7"
      },
      "source": [
        "df_itsok_1 = pd.read_csv(\"/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_itsoknottobeok_1 copy.csv\",\n",
        "                 names=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"])"
      ],
      "execution_count": 28,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 581
        },
        "id": "GD5zNft02yGK",
        "outputId": "22900167-41bb-4c8a-ca74-80db5d1a70e5"
      },
      "source": [
        "df_itsok_1"
      ],
      "execution_count": 29,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1447444376464998400</td>\n",
              "      <td>2021-10-11 06:10:06</td>\n",
              "      <td>Every year passes but the pain remains the sam...</td>\n",
              "      <td>India</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1447517473679441921</td>\n",
              "      <td>2021-10-11 11:00:33</td>\n",
              "      <td>In this life, I can't expect things to be in m...</td>\n",
              "      <td>Davao Region</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1447540227422162949</td>\n",
              "      <td>2021-10-11 12:30:58</td>\n",
              "      <td>holidays can bring on a sense of loss - of fam...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1447564113928863744</td>\n",
              "      <td>2021-10-11 14:05:53</td>\n",
              "      <td>Must be good to have someone by your side. #Lo...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1447599325304000515</td>\n",
              "      <td>2021-10-11 16:25:48</td>\n",
              "      <td>#Artists without an air of #loneliness , are #...</td>\n",
              "      <td>Sulaimanyah, Kurdistan</td>\n",
              "      <td>0</td>\n",
              "      <td>5</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>160</th>\n",
              "      <td>1459084076250546178</td>\n",
              "      <td>2021-11-12 09:02:06</td>\n",
              "      <td>Every problem has a solution if you don’t know...</td>\n",
              "      <td>South East, England</td>\n",
              "      <td>0</td>\n",
              "      <td>10</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>161</th>\n",
              "      <td>1459236894219325441</td>\n",
              "      <td>2021-11-12 19:09:21</td>\n",
              "      <td>I'm loving @calumscott new song, definitely me...</td>\n",
              "      <td>Wrexham, Wales</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>162</th>\n",
              "      <td>1459270946485719041</td>\n",
              "      <td>2021-11-12 21:24:40</td>\n",
              "      <td>You ever stop to acknowledge :  would you look...</td>\n",
              "      <td>United States</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>163</th>\n",
              "      <td>1459429100180111361</td>\n",
              "      <td>2021-11-13 07:53:07</td>\n",
              "      <td>i became teume bcoz of “ #itsokaynottobeokay ”...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>164</th>\n",
              "      <td>1459458776092786694</td>\n",
              "      <td>2021-11-13 09:51:02</td>\n",
              "      <td>I don't usually do this but I just want to tha...</td>\n",
              "      <td>Leicester, England</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>165 rows × 6 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "                tweet.id           created_at  ... retweet favorite\n",
              "0    1447444376464998400  2021-10-11 06:10:06  ...       0        0\n",
              "1    1447517473679441921  2021-10-11 11:00:33  ...       0        0\n",
              "2    1447540227422162949  2021-10-11 12:30:58  ...       0        0\n",
              "3    1447564113928863744  2021-10-11 14:05:53  ...       0        0\n",
              "4    1447599325304000515  2021-10-11 16:25:48  ...       0        5\n",
              "..                   ...                  ...  ...     ...      ...\n",
              "160  1459084076250546178  2021-11-12 09:02:06  ...       0       10\n",
              "161  1459236894219325441  2021-11-12 19:09:21  ...       0        3\n",
              "162  1459270946485719041  2021-11-12 21:24:40  ...       0        2\n",
              "163  1459429100180111361  2021-11-13 07:53:07  ...       0        0\n",
              "164  1459458776092786694  2021-11-13 09:51:02  ...       0        1\n",
              "\n",
              "[165 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 29
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "-RXWp6HY44nN"
      },
      "source": [
        "## \"#depression\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "pbZltJ-k45d5"
      },
      "source": [
        "## Create a function for tweets mining\n",
        "def tweets_mining8(search_query8, num_tweets8, since_id_num8):\n",
        "  # Collect tweets using the Cursor object\n",
        "  # Each item in the iterator has various attributes that you can access to get information about each tweet\n",
        "  tweet_list8 = [tweets for tweets in tweepy.Cursor(api.search, q=search_query8, lang=\"en\", since_id=since_id_num8, \n",
        "                                                    tweet_mode='extended').items(num_tweets8)]\n",
        "  \n",
        "  # Begin scraping the tweets individually:\n",
        "  for tweet in tweet_list8[::-1]:\n",
        "    tweet_id = tweet.id # get Tweet ID result\n",
        "    created_at = tweet.created_at # get time tweet was created\n",
        "    text = tweet.full_text # retrieve full tweet text\n",
        "    location = tweet.user.location # retrieve user location\n",
        "    retweet = tweet.retweet_count # retrieve number of retweets\n",
        "    favorite = tweet.favorite_count # retrieve number of likes\n",
        "    with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_depression_1.csv','a', newline='', encoding='utf-8') as csvFile8:\n",
        "      csv_writer8 = csv.writer(csvFile8, delimiter=',') # create an instance of csv object\n",
        "      csv_writer8.writerow([tweet_id, created_at, text, location, retweet, favorite]) # write each row"
      ],
      "execution_count": 30,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ghHhnfIO5xMg"
      },
      "source": [
        "search_words8 = \"#depression\" # Specifying exact phrase to search\n",
        "# Exclude Links, retweets, replies\n",
        "search_query8 = search_words8 + \" -filter:links AND -filter:retweets AND -filter:replies\"\n",
        "with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_depression_1.csv', encoding='utf-8') as data:\n",
        "    latest_tweet = int(list(csv.reader(data))[-1][0]) \n",
        "tweets_mining8(search_query8, 1000, latest_tweet)"
      ],
      "execution_count": 31,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "2tZbCrCQ6BKL"
      },
      "source": [
        "df_depression_1 = pd.read_csv(\"/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_depression_1.csv\",\n",
        "                 names=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"])"
      ],
      "execution_count": 32,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 581
        },
        "id": "9vYE-YWt6hsd",
        "outputId": "172ccd9a-eb04-4617-eb09-b7bb421126c9"
      },
      "source": [
        "df_depression_1"
      ],
      "execution_count": 33,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1447381882828623879</td>\n",
              "      <td>2021-10-11 02:01:46</td>\n",
              "      <td>#letstalk many suffering from #depression and ...</td>\n",
              "      <td>Chicago, IL</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1447387707362131970</td>\n",
              "      <td>2021-10-11 02:24:55</td>\n",
              "      <td>#Harassmentatwork can lead to debilitating men...</td>\n",
              "      <td>Lahore</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1447396592877805570</td>\n",
              "      <td>2021-10-11 03:00:13</td>\n",
              "      <td>So . . . my #therapist called my wife and told...</td>\n",
              "      <td>If it makes a difference, ask.</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1447398472735342600</td>\n",
              "      <td>2021-10-11 03:07:41</td>\n",
              "      <td>#psychology #love #mentalhealth #therapy #heal...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1447400177510146062</td>\n",
              "      <td>2021-10-11 03:14:28</td>\n",
              "      <td>#psychology #love #mentalhealth #therapy #heal...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>1</td>\n",
              "      <td>4</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4478</th>\n",
              "      <td>1459517445736124420</td>\n",
              "      <td>2021-11-13 13:44:10</td>\n",
              "      <td>I've literally cried atleast once a day for th...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4479</th>\n",
              "      <td>1459521433193877511</td>\n",
              "      <td>2021-11-13 14:00:00</td>\n",
              "      <td>Black cohosh (Cimicifuga racemosa) is a partic...</td>\n",
              "      <td>Global</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4480</th>\n",
              "      <td>1459527712775847936</td>\n",
              "      <td>2021-11-13 14:24:58</td>\n",
              "      <td>I mention therapy to him today, his response \"...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4481</th>\n",
              "      <td>1459531002276192263</td>\n",
              "      <td>2021-11-13 14:38:02</td>\n",
              "      <td>Finna go to dollar tree and get some organizin...</td>\n",
              "      <td>Dallas Texas, USA</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4482</th>\n",
              "      <td>1459532763942604800</td>\n",
              "      <td>2021-11-13 14:45:02</td>\n",
              "      <td>I discovered today that clothes shopping is a ...</td>\n",
              "      <td>England, United Kingdom</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>4483 rows × 6 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "                 tweet.id           created_at  ... retweet favorite\n",
              "0     1447381882828623879  2021-10-11 02:01:46  ...       0        0\n",
              "1     1447387707362131970  2021-10-11 02:24:55  ...       1        1\n",
              "2     1447396592877805570  2021-10-11 03:00:13  ...       0        0\n",
              "3     1447398472735342600  2021-10-11 03:07:41  ...       1        0\n",
              "4     1447400177510146062  2021-10-11 03:14:28  ...       1        4\n",
              "...                   ...                  ...  ...     ...      ...\n",
              "4478  1459517445736124420  2021-11-13 13:44:10  ...       0        0\n",
              "4479  1459521433193877511  2021-11-13 14:00:00  ...       1        1\n",
              "4480  1459527712775847936  2021-11-13 14:24:58  ...       0        1\n",
              "4481  1459531002276192263  2021-11-13 14:38:02  ...       0        0\n",
              "4482  1459532763942604800  2021-11-13 14:45:02  ...       0        1\n",
              "\n",
              "[4483 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 33
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "iaBSFYwsUPaI",
        "outputId": "7b2a0935-671f-4d94-d364-5dc7a7134e12"
      },
      "source": [
        "## Finding unique values in each column\n",
        "for col in df_depression_1:\n",
        "    print(\"There are \", len(df_depression_1[col].unique()), \"unique values in \", col)"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "There are  3185 unique values in  tweet.id\n",
            "There are  3182 unique values in  created_at\n",
            "There are  2818 unique values in  text\n",
            "There are  939 unique values in  location\n",
            "There are  23 unique values in  retweet\n",
            "There are  59 unique values in  favorite\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "N2ZER9SmTPzF"
      },
      "source": [
        "## \"#sad\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "EWSDmH8s6iuZ"
      },
      "source": [
        "## Create a function for tweets mining\n",
        "def tweets_mining9(search_query9, num_tweets9, since_id_num9):\n",
        "  # Collect tweets using the Cursor object\n",
        "  # Each item in the iterator has various attributes that you can access to get information about each tweet\n",
        "  tweet_list9 = [tweets for tweets in tweepy.Cursor(api.search, q=search_query9, lang=\"en\", since_id=since_id_num9, \n",
        "                                                    tweet_mode='extended').items(num_tweets9)]\n",
        "  \n",
        "  # Begin scraping the tweets individually:\n",
        "  for tweet in tweet_list9[::-1]:\n",
        "    tweet_id = tweet.id # get Tweet ID result\n",
        "    created_at = tweet.created_at # get time tweet was created\n",
        "    text = tweet.full_text # retrieve full tweet text\n",
        "    location = tweet.user.location # retrieve user location\n",
        "    retweet = tweet.retweet_count # retrieve number of retweets\n",
        "    favorite = tweet.favorite_count # retrieve number of likes\n",
        "    with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_sad_1.csv','a', newline='', encoding='utf-8') as csvFile9:\n",
        "      csv_writer9 = csv.writer(csvFile9, delimiter=',') # create an instance of csv object\n",
        "      csv_writer9.writerow([tweet_id, created_at, text, location, retweet, favorite]) # write each row"
      ],
      "execution_count": 34,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "5G-4-YnoUAVZ"
      },
      "source": [
        "search_words9 = \"#sad\" # Specifying exact phrase to search\n",
        "# Exclude Links, retweets, replies\n",
        "search_query9 = search_words9 + \" -filter:links AND -filter:retweets AND -filter:replies\" \n",
        "with open('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_sad_1.csv', encoding='utf-8') as data:\n",
        "    latest_tweet = int(list(csv.reader(data))[-1][0]) \n",
        "tweets_mining9(search_query9, 2000, latest_tweet)"
      ],
      "execution_count": 35,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6ivTsYufUKw2"
      },
      "source": [
        "df_sad_1 = pd.read_csv(\"/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/tweets_sad_1.csv\",\n",
        "                 names=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"])"
      ],
      "execution_count": 36,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 581
        },
        "id": "4TjbnQlJUUbA",
        "outputId": "4ab3eb84-3d0c-444b-fa61-6d0b9969d3d2"
      },
      "source": [
        "df_sad_1"
      ],
      "execution_count": 37,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1447386915502792706</td>\n",
              "      <td>2021-10-11 02:21:46</td>\n",
              "      <td>Tried to propose to Todd with an air ring duri...</td>\n",
              "      <td>MD/DC</td>\n",
              "      <td>0</td>\n",
              "      <td>4</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1447389433553096704</td>\n",
              "      <td>2021-10-11 02:31:46</td>\n",
              "      <td>Forgetting to bring a post game pint to pickup...</td>\n",
              "      <td>Canada</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1447390726132625416</td>\n",
              "      <td>2021-10-11 02:36:54</td>\n",
              "      <td>bro wtf i came to school because of him and he...</td>\n",
              "      <td>she / her | cbyf !!</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1447390741706149895</td>\n",
              "      <td>2021-10-11 02:36:58</td>\n",
              "      <td>I agree with @clint_dempsey on the Yanks not w...</td>\n",
              "      <td>Los Angeles, CA</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1447391562380554244</td>\n",
              "      <td>2021-10-11 02:40:14</td>\n",
              "      <td>The amount of people who do not tip for grocer...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3517</th>\n",
              "      <td>1459521498842992642</td>\n",
              "      <td>2021-11-13 14:00:16</td>\n",
              "      <td>Just got banned from a server F #sad</td>\n",
              "      <td>Jakarta Capital Region</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3518</th>\n",
              "      <td>1459521611997003777</td>\n",
              "      <td>2021-11-13 14:00:43</td>\n",
              "      <td>I literally cried during my exam and the cam i...</td>\n",
              "      <td>بيت أمك</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3519</th>\n",
              "      <td>1459524263946326017</td>\n",
              "      <td>2021-11-13 14:11:15</td>\n",
              "      <td>No one can be happy with a guy like me. That's...</td>\n",
              "      <td>Varanasi, Uttar Pradesh, India</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3520</th>\n",
              "      <td>1459530315437785095</td>\n",
              "      <td>2021-11-13 14:35:18</td>\n",
              "      <td>arrived at my house but Am I Home? #deep #sad ...</td>\n",
              "      <td>they19sea</td>\n",
              "      <td>1</td>\n",
              "      <td>3</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3521</th>\n",
              "      <td>1459530643591905284</td>\n",
              "      <td>2021-11-13 14:36:36</td>\n",
              "      <td>Being spoken down to rn at @starbucks and reme...</td>\n",
              "      <td>Night Vale, USA</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>3522 rows × 6 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "                 tweet.id           created_at  ... retweet favorite\n",
              "0     1447386915502792706  2021-10-11 02:21:46  ...       0        4\n",
              "1     1447389433553096704  2021-10-11 02:31:46  ...       0        1\n",
              "2     1447390726132625416  2021-10-11 02:36:54  ...       0        0\n",
              "3     1447390741706149895  2021-10-11 02:36:58  ...       0        0\n",
              "4     1447391562380554244  2021-10-11 02:40:14  ...       0        1\n",
              "...                   ...                  ...  ...     ...      ...\n",
              "3517  1459521498842992642  2021-11-13 14:00:16  ...       0        1\n",
              "3518  1459521611997003777  2021-11-13 14:00:43  ...       0        0\n",
              "3519  1459524263946326017  2021-11-13 14:11:15  ...       0        0\n",
              "3520  1459530315437785095  2021-11-13 14:35:18  ...       1        3\n",
              "3521  1459530643591905284  2021-11-13 14:36:36  ...       0        0\n",
              "\n",
              "[3522 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 37
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "WMQTcPwD38hP"
      },
      "source": [
        "# Combining all the tweets"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "aGjcg4Et6ZR9"
      },
      "source": [
        "import glob"
      ],
      "execution_count": 38,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 285
        },
        "id": "FVBUCENZ4BIQ",
        "outputId": "e06fbce1-e125-4ff4-c763-b128e9acf2ea"
      },
      "source": [
        "path = r'/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API'  # use your path\n",
        "all_files = glob.glob(path + \"/*.csv\")\n",
        "\n",
        "tweets = []\n",
        "\n",
        "for filename in all_files:\n",
        "    df = pd.read_csv(filename, \n",
        "                     names=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"]) # Convert each csv to a dataframe\n",
        "    tweets.append(df)\n",
        "\n",
        "tweets_df = pd.concat(tweets, ignore_index=True) # Merge all dataframes\n",
        "#tweets_df.columns=['tweet.id', \"created_at\",\"text\", \"location\", \"retweet\", \"favorite\"]\n",
        "tweets_df.head()"
      ],
      "execution_count": 39,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1447537898572574730</td>\n",
              "      <td>2021-10-11 12:21:43</td>\n",
              "      <td>Open discussion. Between the Transfer Portal a...</td>\n",
              "      <td>Cheyenne Wyoming</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1447540582490988553</td>\n",
              "      <td>2021-10-11 12:32:23</td>\n",
              "      <td>Plenty of things are changing in my life and t...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1447807717859491842</td>\n",
              "      <td>2021-10-12 06:13:53</td>\n",
              "      <td>I feel a little hopeless. Anyone else? #hopele...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1448076026219692033</td>\n",
              "      <td>2021-10-13 00:00:03</td>\n",
              "      <td>Which is more healthy? Hope, or hopelessness? ...</td>\n",
              "      <td>Denver, CO</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1448382047375040513</td>\n",
              "      <td>2021-10-13 20:16:04</td>\n",
              "      <td>So someone tell me how do I get over #HOPELESS...</td>\n",
              "      <td>Portland Or .</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "              tweet.id           created_at  ... retweet favorite\n",
              "0  1447537898572574730  2021-10-11 12:21:43  ...       0        0\n",
              "1  1447540582490988553  2021-10-11 12:32:23  ...       0        0\n",
              "2  1447807717859491842  2021-10-12 06:13:53  ...       0        0\n",
              "3  1448076026219692033  2021-10-13 00:00:03  ...       0        0\n",
              "4  1448382047375040513  2021-10-13 20:16:04  ...       0        2\n",
              "\n",
              "[5 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 39
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 581
        },
        "id": "NIh6Pc_C5BmN",
        "outputId": "6ceba47d-7e76-49e4-f459-8b78860e6aae"
      },
      "source": [
        "tweets_df"
      ],
      "execution_count": 40,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>tweet.id</th>\n",
              "      <th>created_at</th>\n",
              "      <th>text</th>\n",
              "      <th>location</th>\n",
              "      <th>retweet</th>\n",
              "      <th>favorite</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1447537898572574730</td>\n",
              "      <td>2021-10-11 12:21:43</td>\n",
              "      <td>Open discussion. Between the Transfer Portal a...</td>\n",
              "      <td>Cheyenne Wyoming</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1447540582490988553</td>\n",
              "      <td>2021-10-11 12:32:23</td>\n",
              "      <td>Plenty of things are changing in my life and t...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1447807717859491842</td>\n",
              "      <td>2021-10-12 06:13:53</td>\n",
              "      <td>I feel a little hopeless. Anyone else? #hopele...</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1448076026219692033</td>\n",
              "      <td>2021-10-13 00:00:03</td>\n",
              "      <td>Which is more healthy? Hope, or hopelessness? ...</td>\n",
              "      <td>Denver, CO</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>1448382047375040513</td>\n",
              "      <td>2021-10-13 20:16:04</td>\n",
              "      <td>So someone tell me how do I get over #HOPELESS...</td>\n",
              "      <td>Portland Or .</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>24142</th>\n",
              "      <td>1459521498842992642</td>\n",
              "      <td>2021-11-13 14:00:16</td>\n",
              "      <td>Just got banned from a server F #sad</td>\n",
              "      <td>Jakarta Capital Region</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>24143</th>\n",
              "      <td>1459521611997003777</td>\n",
              "      <td>2021-11-13 14:00:43</td>\n",
              "      <td>I literally cried during my exam and the cam i...</td>\n",
              "      <td>بيت أمك</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>24144</th>\n",
              "      <td>1459524263946326017</td>\n",
              "      <td>2021-11-13 14:11:15</td>\n",
              "      <td>No one can be happy with a guy like me. That's...</td>\n",
              "      <td>Varanasi, Uttar Pradesh, India</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>24145</th>\n",
              "      <td>1459530315437785095</td>\n",
              "      <td>2021-11-13 14:35:18</td>\n",
              "      <td>arrived at my house but Am I Home? #deep #sad ...</td>\n",
              "      <td>they19sea</td>\n",
              "      <td>1</td>\n",
              "      <td>3</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>24146</th>\n",
              "      <td>1459530643591905284</td>\n",
              "      <td>2021-11-13 14:36:36</td>\n",
              "      <td>Being spoken down to rn at @starbucks and reme...</td>\n",
              "      <td>Night Vale, USA</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>24147 rows × 6 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "                  tweet.id           created_at  ... retweet favorite\n",
              "0      1447537898572574730  2021-10-11 12:21:43  ...       0        0\n",
              "1      1447540582490988553  2021-10-11 12:32:23  ...       0        0\n",
              "2      1447807717859491842  2021-10-12 06:13:53  ...       0        0\n",
              "3      1448076026219692033  2021-10-13 00:00:03  ...       0        0\n",
              "4      1448382047375040513  2021-10-13 20:16:04  ...       0        2\n",
              "...                    ...                  ...  ...     ...      ...\n",
              "24142  1459521498842992642  2021-11-13 14:00:16  ...       0        1\n",
              "24143  1459521611997003777  2021-11-13 14:00:43  ...       0        0\n",
              "24144  1459524263946326017  2021-11-13 14:11:15  ...       0        0\n",
              "24145  1459530315437785095  2021-11-13 14:35:18  ...       1        3\n",
              "24146  1459530643591905284  2021-11-13 14:36:36  ...       0        0\n",
              "\n",
              "[24147 rows x 6 columns]"
            ]
          },
          "metadata": {},
          "execution_count": 40
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Yia0nXGnQsiV"
      },
      "source": [
        "tweets_df.to_csv('/content/drive/MyDrive/NLP/Depression_Detection/Data_fetch_API/output/depressive_tweets.csv')"
      ],
      "execution_count": 41,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Zvj3hdFwO2IO"
      },
      "source": [
        "## Data cleaning"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "GEBn1OyhPDp1"
      },
      "source": [
        "Data cleaning is one of the essential steps because without a proper cleaning procedure you will have errors in your analysis and eventually your data-driven results. Here I try to eliminate duplicates tweets by using the Primary key ('tweets.id'), checked for empty rows and replaced “NaN” if there is any."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "zgrxs9HGOhnN",
        "outputId": "f8886c9b-28b7-4429-ebe0-b91ad894f32b"
      },
      "source": [
        "tweets_df.shape #Get number of rows and columns"
      ],
      "execution_count": 42,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "(24147, 6)"
            ]
          },
          "metadata": {},
          "execution_count": 42
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 232
        },
        "id": "s6rb-N77QIA-",
        "outputId": "ae758d07-1cbc-4bc8-988f-8f38777ac201"
      },
      "source": [
        "## Check the data type of each column\n",
        "tweets_df.dtypes.to_frame().rename(columns={0:'data_type'})"
      ],
      "execution_count": 43,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>data_type</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>tweet.id</th>\n",
              "      <td>int64</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>created_at</th>\n",
              "      <td>object</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>text</th>\n",
              "      <td>object</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>location</th>\n",
              "      <td>object</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>retweet</th>\n",
              "      <td>int64</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>favorite</th>\n",
              "      <td>int64</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "           data_type\n",
              "tweet.id       int64\n",
              "created_at    object\n",
              "text          object\n",
              "location      object\n",
              "retweet        int64\n",
              "favorite       int64"
            ]
          },
          "metadata": {},
          "execution_count": 43
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "mYuqjbWiPJVK",
        "outputId": "997390f8-38b1-41d6-a94d-d3b25ba402c4"
      },
      "source": [
        "## Finding unique values in each column\n",
        "for col in tweets_df:\n",
        "    print(\"There are \", len(tweets_df[col].unique()), \"unique values in \", col)"
      ],
      "execution_count": 45,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "There are  18190 unique values in  tweet.id\n",
            "There are  18071 unique values in  created_at\n",
            "There are  17107 unique values in  text\n",
            "There are  4648 unique values in  location\n",
            "There are  74 unique values in  retweet\n",
            "There are  159 unique values in  favorite\n"
          ]
        }
      ]
    }
  ]
}