cpatel321 commited on
Commit
9da21e6
·
1 Parent(s): 2873ff2

jupyter to create dataset

Browse files
Files changed (1) hide show
  1. 2000s_to_dataset.ipynb +639 -0
2000s_to_dataset.ipynb ADDED
@@ -0,0 +1,639 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 41,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "\n",
10
+ "import pandas as pd\n",
11
+ "import numpy as np\n",
12
+ "\n",
13
+ "# read csv file\n",
14
+ "df = pd.read_csv('2000s_normalized.csv')"
15
+ ]
16
+ },
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": 42,
20
+ "metadata": {},
21
+ "outputs": [
22
+ {
23
+ "data": {
24
+ "text/html": [
25
+ "<div>\n",
26
+ "<style scoped>\n",
27
+ " .dataframe tbody tr th:only-of-type {\n",
28
+ " vertical-align: middle;\n",
29
+ " }\n",
30
+ "\n",
31
+ " .dataframe tbody tr th {\n",
32
+ " vertical-align: top;\n",
33
+ " }\n",
34
+ "\n",
35
+ " .dataframe thead th {\n",
36
+ " text-align: right;\n",
37
+ " }\n",
38
+ "</style>\n",
39
+ "<table border=\"1\" class=\"dataframe\">\n",
40
+ " <thead>\n",
41
+ " <tr style=\"text-align: right;\">\n",
42
+ " <th></th>\n",
43
+ " <th>id</th>\n",
44
+ " <th>content</th>\n",
45
+ " <th>normalized_tweet</th>\n",
46
+ " </tr>\n",
47
+ " </thead>\n",
48
+ " <tbody>\n",
49
+ " <tr>\n",
50
+ " <th>0</th>\n",
51
+ " <td>1</td>\n",
52
+ " <td>Spend your weekend morning with a Ham, Egg, an...</td>\n",
53
+ " <td>Spend your weekend morning with a Ham , Egg , ...</td>\n",
54
+ " </tr>\n",
55
+ " <tr>\n",
56
+ " <th>1</th>\n",
57
+ " <td>2</td>\n",
58
+ " <td>Watch rapper &lt;mention&gt; freestyle for over an H...</td>\n",
59
+ " <td>Watch rapper &lt;mention&gt; freestyle for over an H...</td>\n",
60
+ " </tr>\n",
61
+ " <tr>\n",
62
+ " <th>2</th>\n",
63
+ " <td>3</td>\n",
64
+ " <td>Canadian Armenian community demands ban on mil...</td>\n",
65
+ " <td>Canadian Armenian community demands ban on mil...</td>\n",
66
+ " </tr>\n",
67
+ " <tr>\n",
68
+ " <th>3</th>\n",
69
+ " <td>4</td>\n",
70
+ " <td>1st in Europe to be devastated by COVID-19, It...</td>\n",
71
+ " <td>1st in Europe to be devastated by COVID - 19 ,...</td>\n",
72
+ " </tr>\n",
73
+ " <tr>\n",
74
+ " <th>4</th>\n",
75
+ " <td>5</td>\n",
76
+ " <td>Congratulations to Pauletha Butts of &lt;mention&gt;...</td>\n",
77
+ " <td>Congratulations to Pauletha Butts of &lt;mention&gt;...</td>\n",
78
+ " </tr>\n",
79
+ " <tr>\n",
80
+ " <th>5</th>\n",
81
+ " <td>7</td>\n",
82
+ " <td>LASU Celebrates New Dawn Of Unbroken Peace As ...</td>\n",
83
+ " <td>LASU Celebrates New Dawn Of Unbroken Peace As ...</td>\n",
84
+ " </tr>\n",
85
+ " <tr>\n",
86
+ " <th>6</th>\n",
87
+ " <td>9</td>\n",
88
+ " <td>A 95-year-old World War II veteran says he was...</td>\n",
89
+ " <td>A 95 - year-old World War II veteran says he w...</td>\n",
90
+ " </tr>\n",
91
+ " <tr>\n",
92
+ " <th>7</th>\n",
93
+ " <td>10</td>\n",
94
+ " <td>Nicholas Hoult, Charlize Theron, and Aisha Tyl...</td>\n",
95
+ " <td>Nicholas Hoult , Charlize Theron , and Aisha T...</td>\n",
96
+ " </tr>\n",
97
+ " <tr>\n",
98
+ " <th>8</th>\n",
99
+ " <td>11</td>\n",
100
+ " <td>.&lt;mention&gt; takes the stage at #BHUSA to talk a...</td>\n",
101
+ " <td>. &lt;mention&gt; takes the stage at #BHUSA to talk ...</td>\n",
102
+ " </tr>\n",
103
+ " <tr>\n",
104
+ " <th>9</th>\n",
105
+ " <td>12</td>\n",
106
+ " <td>#NetZeroHomes: learn the best way to get to ze...</td>\n",
107
+ " <td>#NetZeroHomes : learn the best way to get to z...</td>\n",
108
+ " </tr>\n",
109
+ " <tr>\n",
110
+ " <th>10</th>\n",
111
+ " <td>15</td>\n",
112
+ " <td>Survivors of the Parkland shooting were awarde...</td>\n",
113
+ " <td>Survivors of the Parkland shooting were awarde...</td>\n",
114
+ " </tr>\n",
115
+ " <tr>\n",
116
+ " <th>11</th>\n",
117
+ " <td>19</td>\n",
118
+ " <td>Linda Ikeji Partners ECOBANK To Empower Young ...</td>\n",
119
+ " <td>Linda Ikeji Partners ECOBANK To Empower Young ...</td>\n",
120
+ " </tr>\n",
121
+ " <tr>\n",
122
+ " <th>12</th>\n",
123
+ " <td>20</td>\n",
124
+ " <td>LOOK: World-class singers Darren Espanto &lt;ment...</td>\n",
125
+ " <td>LOOK : World-class singers Darren Espanto &lt;men...</td>\n",
126
+ " </tr>\n",
127
+ " <tr>\n",
128
+ " <th>13</th>\n",
129
+ " <td>21</td>\n",
130
+ " <td>.&lt;mention&gt; is investing $1.5 billion into next...</td>\n",
131
+ " <td>. &lt;mention&gt; is investing $ 1.5 billion into ne...</td>\n",
132
+ " </tr>\n",
133
+ " <tr>\n",
134
+ " <th>14</th>\n",
135
+ " <td>22</td>\n",
136
+ " <td>Supreme Court Chief Justice John Roberts makes...</td>\n",
137
+ " <td>Supreme Court Chief Justice John Roberts makes...</td>\n",
138
+ " </tr>\n",
139
+ " <tr>\n",
140
+ " <th>15</th>\n",
141
+ " <td>23</td>\n",
142
+ " <td>Tournaments come and go, but the pictures are ...</td>\n",
143
+ " <td>Tournaments come and go , but the pictures are...</td>\n",
144
+ " </tr>\n",
145
+ " <tr>\n",
146
+ " <th>16</th>\n",
147
+ " <td>24</td>\n",
148
+ " <td>Twitter suspends 70 pro-Bloomberg accounts for...</td>\n",
149
+ " <td>Twitter suspends 70 pro-Bloomberg accounts for...</td>\n",
150
+ " </tr>\n",
151
+ " <tr>\n",
152
+ " <th>17</th>\n",
153
+ " <td>25</td>\n",
154
+ " <td>Many people are understandably anxious to get ...</td>\n",
155
+ " <td>Many people are understandably anxious to get ...</td>\n",
156
+ " </tr>\n",
157
+ " <tr>\n",
158
+ " <th>18</th>\n",
159
+ " <td>27</td>\n",
160
+ " <td>ALSO NOW (yes it's wild here today): Sen Merkl...</td>\n",
161
+ " <td>ALSO NOW ( yes it 's wild here today ): Sen Me...</td>\n",
162
+ " </tr>\n",
163
+ " <tr>\n",
164
+ " <th>19</th>\n",
165
+ " <td>28</td>\n",
166
+ " <td>We got a sneak peek at Star Wars Jedi: Fallen ...</td>\n",
167
+ " <td>We got a sneak peek at Star Wars Jedi : Fallen...</td>\n",
168
+ " </tr>\n",
169
+ " </tbody>\n",
170
+ "</table>\n",
171
+ "</div>"
172
+ ],
173
+ "text/plain": [
174
+ " id content \\\n",
175
+ "0 1 Spend your weekend morning with a Ham, Egg, an... \n",
176
+ "1 2 Watch rapper <mention> freestyle for over an H... \n",
177
+ "2 3 Canadian Armenian community demands ban on mil... \n",
178
+ "3 4 1st in Europe to be devastated by COVID-19, It... \n",
179
+ "4 5 Congratulations to Pauletha Butts of <mention>... \n",
180
+ "5 7 LASU Celebrates New Dawn Of Unbroken Peace As ... \n",
181
+ "6 9 A 95-year-old World War II veteran says he was... \n",
182
+ "7 10 Nicholas Hoult, Charlize Theron, and Aisha Tyl... \n",
183
+ "8 11 .<mention> takes the stage at #BHUSA to talk a... \n",
184
+ "9 12 #NetZeroHomes: learn the best way to get to ze... \n",
185
+ "10 15 Survivors of the Parkland shooting were awarde... \n",
186
+ "11 19 Linda Ikeji Partners ECOBANK To Empower Young ... \n",
187
+ "12 20 LOOK: World-class singers Darren Espanto <ment... \n",
188
+ "13 21 .<mention> is investing $1.5 billion into next... \n",
189
+ "14 22 Supreme Court Chief Justice John Roberts makes... \n",
190
+ "15 23 Tournaments come and go, but the pictures are ... \n",
191
+ "16 24 Twitter suspends 70 pro-Bloomberg accounts for... \n",
192
+ "17 25 Many people are understandably anxious to get ... \n",
193
+ "18 27 ALSO NOW (yes it's wild here today): Sen Merkl... \n",
194
+ "19 28 We got a sneak peek at Star Wars Jedi: Fallen ... \n",
195
+ "\n",
196
+ " normalized_tweet \n",
197
+ "0 Spend your weekend morning with a Ham , Egg , ... \n",
198
+ "1 Watch rapper <mention> freestyle for over an H... \n",
199
+ "2 Canadian Armenian community demands ban on mil... \n",
200
+ "3 1st in Europe to be devastated by COVID - 19 ,... \n",
201
+ "4 Congratulations to Pauletha Butts of <mention>... \n",
202
+ "5 LASU Celebrates New Dawn Of Unbroken Peace As ... \n",
203
+ "6 A 95 - year-old World War II veteran says he w... \n",
204
+ "7 Nicholas Hoult , Charlize Theron , and Aisha T... \n",
205
+ "8 . <mention> takes the stage at #BHUSA to talk ... \n",
206
+ "9 #NetZeroHomes : learn the best way to get to z... \n",
207
+ "10 Survivors of the Parkland shooting were awarde... \n",
208
+ "11 Linda Ikeji Partners ECOBANK To Empower Young ... \n",
209
+ "12 LOOK : World-class singers Darren Espanto <men... \n",
210
+ "13 . <mention> is investing $ 1.5 billion into ne... \n",
211
+ "14 Supreme Court Chief Justice John Roberts makes... \n",
212
+ "15 Tournaments come and go , but the pictures are... \n",
213
+ "16 Twitter suspends 70 pro-Bloomberg accounts for... \n",
214
+ "17 Many people are understandably anxious to get ... \n",
215
+ "18 ALSO NOW ( yes it 's wild here today ): Sen Me... \n",
216
+ "19 We got a sneak peek at Star Wars Jedi : Fallen... "
217
+ ]
218
+ },
219
+ "execution_count": 42,
220
+ "metadata": {},
221
+ "output_type": "execute_result"
222
+ }
223
+ ],
224
+ "source": [
225
+ "# drop content column\n",
226
+ "\n",
227
+ "# drop Unnamed: 0 column\n",
228
+ "df = df.drop(columns=['Unnamed: 0'])\n",
229
+ "df.head(20)"
230
+ ]
231
+ },
232
+ {
233
+ "cell_type": "code",
234
+ "execution_count": 43,
235
+ "metadata": {},
236
+ "outputs": [
237
+ {
238
+ "data": {
239
+ "text/html": [
240
+ "<div>\n",
241
+ "<style scoped>\n",
242
+ " .dataframe tbody tr th:only-of-type {\n",
243
+ " vertical-align: middle;\n",
244
+ " }\n",
245
+ "\n",
246
+ " .dataframe tbody tr th {\n",
247
+ " vertical-align: top;\n",
248
+ " }\n",
249
+ "\n",
250
+ " .dataframe thead th {\n",
251
+ " text-align: right;\n",
252
+ " }\n",
253
+ "</style>\n",
254
+ "<table border=\"1\" class=\"dataframe\">\n",
255
+ " <thead>\n",
256
+ " <tr style=\"text-align: right;\">\n",
257
+ " <th></th>\n",
258
+ " <th>id</th>\n",
259
+ " <th>normalized_tweet</th>\n",
260
+ " </tr>\n",
261
+ " </thead>\n",
262
+ " <tbody>\n",
263
+ " <tr>\n",
264
+ " <th>0</th>\n",
265
+ " <td>1</td>\n",
266
+ " <td>Spend your weekend morning with a Ham , Egg , ...</td>\n",
267
+ " </tr>\n",
268
+ " <tr>\n",
269
+ " <th>1</th>\n",
270
+ " <td>2</td>\n",
271
+ " <td>Watch rapper &lt;mention&gt; freestyle for over an H...</td>\n",
272
+ " </tr>\n",
273
+ " <tr>\n",
274
+ " <th>2</th>\n",
275
+ " <td>3</td>\n",
276
+ " <td>Canadian Armenian community demands ban on mil...</td>\n",
277
+ " </tr>\n",
278
+ " <tr>\n",
279
+ " <th>3</th>\n",
280
+ " <td>4</td>\n",
281
+ " <td>1st in Europe to be devastated by COVID - 19 ,...</td>\n",
282
+ " </tr>\n",
283
+ " <tr>\n",
284
+ " <th>4</th>\n",
285
+ " <td>5</td>\n",
286
+ " <td>Congratulations to Pauletha Butts of &lt;mention&gt;...</td>\n",
287
+ " </tr>\n",
288
+ " <tr>\n",
289
+ " <th>5</th>\n",
290
+ " <td>7</td>\n",
291
+ " <td>LASU Celebrates New Dawn Of Unbroken Peace As ...</td>\n",
292
+ " </tr>\n",
293
+ " <tr>\n",
294
+ " <th>6</th>\n",
295
+ " <td>9</td>\n",
296
+ " <td>A 95 - year-old World War II veteran says he w...</td>\n",
297
+ " </tr>\n",
298
+ " <tr>\n",
299
+ " <th>7</th>\n",
300
+ " <td>10</td>\n",
301
+ " <td>Nicholas Hoult , Charlize Theron , and Aisha T...</td>\n",
302
+ " </tr>\n",
303
+ " <tr>\n",
304
+ " <th>8</th>\n",
305
+ " <td>11</td>\n",
306
+ " <td>. &lt;mention&gt; takes the stage at #BHUSA to talk ...</td>\n",
307
+ " </tr>\n",
308
+ " <tr>\n",
309
+ " <th>9</th>\n",
310
+ " <td>12</td>\n",
311
+ " <td>#NetZeroHomes : learn the best way to get to z...</td>\n",
312
+ " </tr>\n",
313
+ " <tr>\n",
314
+ " <th>10</th>\n",
315
+ " <td>15</td>\n",
316
+ " <td>Survivors of the Parkland shooting were awarde...</td>\n",
317
+ " </tr>\n",
318
+ " <tr>\n",
319
+ " <th>11</th>\n",
320
+ " <td>19</td>\n",
321
+ " <td>Linda Ikeji Partners ECOBANK To Empower Young ...</td>\n",
322
+ " </tr>\n",
323
+ " <tr>\n",
324
+ " <th>12</th>\n",
325
+ " <td>20</td>\n",
326
+ " <td>LOOK : World-class singers Darren Espanto &lt;men...</td>\n",
327
+ " </tr>\n",
328
+ " <tr>\n",
329
+ " <th>13</th>\n",
330
+ " <td>21</td>\n",
331
+ " <td>. &lt;mention&gt; is investing $ 1.5 billion into ne...</td>\n",
332
+ " </tr>\n",
333
+ " <tr>\n",
334
+ " <th>14</th>\n",
335
+ " <td>22</td>\n",
336
+ " <td>Supreme Court Chief Justice John Roberts makes...</td>\n",
337
+ " </tr>\n",
338
+ " <tr>\n",
339
+ " <th>15</th>\n",
340
+ " <td>23</td>\n",
341
+ " <td>Tournaments come and go , but the pictures are...</td>\n",
342
+ " </tr>\n",
343
+ " <tr>\n",
344
+ " <th>16</th>\n",
345
+ " <td>24</td>\n",
346
+ " <td>Twitter suspends 70 pro-Bloomberg accounts for...</td>\n",
347
+ " </tr>\n",
348
+ " <tr>\n",
349
+ " <th>17</th>\n",
350
+ " <td>25</td>\n",
351
+ " <td>Many people are understandably anxious to get ...</td>\n",
352
+ " </tr>\n",
353
+ " <tr>\n",
354
+ " <th>18</th>\n",
355
+ " <td>27</td>\n",
356
+ " <td>ALSO NOW ( yes it 's wild here today ): Sen Me...</td>\n",
357
+ " </tr>\n",
358
+ " <tr>\n",
359
+ " <th>19</th>\n",
360
+ " <td>28</td>\n",
361
+ " <td>We got a sneak peek at Star Wars Jedi : Fallen...</td>\n",
362
+ " </tr>\n",
363
+ " </tbody>\n",
364
+ "</table>\n",
365
+ "</div>"
366
+ ],
367
+ "text/plain": [
368
+ " id normalized_tweet\n",
369
+ "0 1 Spend your weekend morning with a Ham , Egg , ...\n",
370
+ "1 2 Watch rapper <mention> freestyle for over an H...\n",
371
+ "2 3 Canadian Armenian community demands ban on mil...\n",
372
+ "3 4 1st in Europe to be devastated by COVID - 19 ,...\n",
373
+ "4 5 Congratulations to Pauletha Butts of <mention>...\n",
374
+ "5 7 LASU Celebrates New Dawn Of Unbroken Peace As ...\n",
375
+ "6 9 A 95 - year-old World War II veteran says he w...\n",
376
+ "7 10 Nicholas Hoult , Charlize Theron , and Aisha T...\n",
377
+ "8 11 . <mention> takes the stage at #BHUSA to talk ...\n",
378
+ "9 12 #NetZeroHomes : learn the best way to get to z...\n",
379
+ "10 15 Survivors of the Parkland shooting were awarde...\n",
380
+ "11 19 Linda Ikeji Partners ECOBANK To Empower Young ...\n",
381
+ "12 20 LOOK : World-class singers Darren Espanto <men...\n",
382
+ "13 21 . <mention> is investing $ 1.5 billion into ne...\n",
383
+ "14 22 Supreme Court Chief Justice John Roberts makes...\n",
384
+ "15 23 Tournaments come and go , but the pictures are...\n",
385
+ "16 24 Twitter suspends 70 pro-Bloomberg accounts for...\n",
386
+ "17 25 Many people are understandably anxious to get ...\n",
387
+ "18 27 ALSO NOW ( yes it 's wild here today ): Sen Me...\n",
388
+ "19 28 We got a sneak peek at Star Wars Jedi : Fallen..."
389
+ ]
390
+ },
391
+ "execution_count": 43,
392
+ "metadata": {},
393
+ "output_type": "execute_result"
394
+ }
395
+ ],
396
+ "source": [
397
+ "# drop content column and rename normalized_content to content\n",
398
+ "df = df.drop(columns=['content'])\n",
399
+ "\n",
400
+ "df.head(20)"
401
+ ]
402
+ },
403
+ {
404
+ "cell_type": "code",
405
+ "execution_count": 44,
406
+ "metadata": {},
407
+ "outputs": [],
408
+ "source": [
409
+ "df = df.rename(columns={'normalized_tweet': 'caption'})"
410
+ ]
411
+ },
412
+ {
413
+ "cell_type": "code",
414
+ "execution_count": 45,
415
+ "metadata": {},
416
+ "outputs": [
417
+ {
418
+ "data": {
419
+ "text/html": [
420
+ "<div>\n",
421
+ "<style scoped>\n",
422
+ " .dataframe tbody tr th:only-of-type {\n",
423
+ " vertical-align: middle;\n",
424
+ " }\n",
425
+ "\n",
426
+ " .dataframe tbody tr th {\n",
427
+ " vertical-align: top;\n",
428
+ " }\n",
429
+ "\n",
430
+ " .dataframe thead th {\n",
431
+ " text-align: right;\n",
432
+ " }\n",
433
+ "</style>\n",
434
+ "<table border=\"1\" class=\"dataframe\">\n",
435
+ " <thead>\n",
436
+ " <tr style=\"text-align: right;\">\n",
437
+ " <th></th>\n",
438
+ " <th>id</th>\n",
439
+ " <th>caption</th>\n",
440
+ " </tr>\n",
441
+ " </thead>\n",
442
+ " <tbody>\n",
443
+ " <tr>\n",
444
+ " <th>1378</th>\n",
445
+ " <td>1961</td>\n",
446
+ " <td>Looking for great monsoon getaways #ThisWeeken...</td>\n",
447
+ " </tr>\n",
448
+ " <tr>\n",
449
+ " <th>1379</th>\n",
450
+ " <td>1964</td>\n",
451
+ " <td>Cisco launches Meraki Insight - creating fast ...</td>\n",
452
+ " </tr>\n",
453
+ " <tr>\n",
454
+ " <th>1380</th>\n",
455
+ " <td>1967</td>\n",
456
+ " <td>💅🏾 Survived on crumbs for 35 years , worked my...</td>\n",
457
+ " </tr>\n",
458
+ " <tr>\n",
459
+ " <th>1381</th>\n",
460
+ " <td>1969</td>\n",
461
+ " <td>Sule Hands Over Building Complex To Federal Va...</td>\n",
462
+ " </tr>\n",
463
+ " <tr>\n",
464
+ " <th>1382</th>\n",
465
+ " <td>1971</td>\n",
466
+ " <td>Court Sentences Man , 21 , To 8 Months Communi...</td>\n",
467
+ " </tr>\n",
468
+ " <tr>\n",
469
+ " <th>1383</th>\n",
470
+ " <td>1972</td>\n",
471
+ " <td>Hear about Cisco Umbrella from 335 verified Te...</td>\n",
472
+ " </tr>\n",
473
+ " <tr>\n",
474
+ " <th>1384</th>\n",
475
+ " <td>1975</td>\n",
476
+ " <td>Shashi , who was part of the core team that le...</td>\n",
477
+ " </tr>\n",
478
+ " <tr>\n",
479
+ " <th>1385</th>\n",
480
+ " <td>1976</td>\n",
481
+ " <td>Will be phoning you at #NewYear #Happy2019 - a...</td>\n",
482
+ " </tr>\n",
483
+ " <tr>\n",
484
+ " <th>1386</th>\n",
485
+ " <td>1977</td>\n",
486
+ " <td>Here 's where &lt;mention&gt; and &lt;mention&gt; sit foll...</td>\n",
487
+ " </tr>\n",
488
+ " <tr>\n",
489
+ " <th>1387</th>\n",
490
+ " <td>1980</td>\n",
491
+ " <td>Best players in the World according to Gary Li...</td>\n",
492
+ " </tr>\n",
493
+ " <tr>\n",
494
+ " <th>1388</th>\n",
495
+ " <td>1983</td>\n",
496
+ " <td>The man behind the USS Cole attack that killed...</td>\n",
497
+ " </tr>\n",
498
+ " <tr>\n",
499
+ " <th>1389</th>\n",
500
+ " <td>1986</td>\n",
501
+ " <td>Trump is on a Nixonian collision course with t...</td>\n",
502
+ " </tr>\n",
503
+ " <tr>\n",
504
+ " <th>1390</th>\n",
505
+ " <td>1987</td>\n",
506
+ " <td>#Cisco #SDWAN securely connects everything eve...</td>\n",
507
+ " </tr>\n",
508
+ " <tr>\n",
509
+ " <th>1391</th>\n",
510
+ " <td>1989</td>\n",
511
+ " <td>How Africa Risks Reeling From A Health Crisis ...</td>\n",
512
+ " </tr>\n",
513
+ " <tr>\n",
514
+ " <th>1392</th>\n",
515
+ " <td>1990</td>\n",
516
+ " <td>Women kayakers win Canada 's 1st Pan Am Games ...</td>\n",
517
+ " </tr>\n",
518
+ " <tr>\n",
519
+ " <th>1393</th>\n",
520
+ " <td>1991</td>\n",
521
+ " <td>IT'S OFFICIAL : Arsenal have confirmed that Da...</td>\n",
522
+ " </tr>\n",
523
+ " <tr>\n",
524
+ " <th>1394</th>\n",
525
+ " <td>1995</td>\n",
526
+ " <td>Messi Masterclass On Display As Barcelona Thra...</td>\n",
527
+ " </tr>\n",
528
+ " <tr>\n",
529
+ " <th>1395</th>\n",
530
+ " <td>1997</td>\n",
531
+ " <td>Are you under constant pressure to connect use...</td>\n",
532
+ " </tr>\n",
533
+ " <tr>\n",
534
+ " <th>1396</th>\n",
535
+ " <td>1998</td>\n",
536
+ " <td>Shun Ethnic Prejudice , Religious Intolerance ...</td>\n",
537
+ " </tr>\n",
538
+ " <tr>\n",
539
+ " <th>1397</th>\n",
540
+ " <td>2000</td>\n",
541
+ " <td>Encrypted On-Prem Connections to Public Clouds...</td>\n",
542
+ " </tr>\n",
543
+ " </tbody>\n",
544
+ "</table>\n",
545
+ "</div>"
546
+ ],
547
+ "text/plain": [
548
+ " id caption\n",
549
+ "1378 1961 Looking for great monsoon getaways #ThisWeeken...\n",
550
+ "1379 1964 Cisco launches Meraki Insight - creating fast ...\n",
551
+ "1380 1967 💅🏾 Survived on crumbs for 35 years , worked my...\n",
552
+ "1381 1969 Sule Hands Over Building Complex To Federal Va...\n",
553
+ "1382 1971 Court Sentences Man , 21 , To 8 Months Communi...\n",
554
+ "1383 1972 Hear about Cisco Umbrella from 335 verified Te...\n",
555
+ "1384 1975 Shashi , who was part of the core team that le...\n",
556
+ "1385 1976 Will be phoning you at #NewYear #Happy2019 - a...\n",
557
+ "1386 1977 Here 's where <mention> and <mention> sit foll...\n",
558
+ "1387 1980 Best players in the World according to Gary Li...\n",
559
+ "1388 1983 The man behind the USS Cole attack that killed...\n",
560
+ "1389 1986 Trump is on a Nixonian collision course with t...\n",
561
+ "1390 1987 #Cisco #SDWAN securely connects everything eve...\n",
562
+ "1391 1989 How Africa Risks Reeling From A Health Crisis ...\n",
563
+ "1392 1990 Women kayakers win Canada 's 1st Pan Am Games ...\n",
564
+ "1393 1991 IT'S OFFICIAL : Arsenal have confirmed that Da...\n",
565
+ "1394 1995 Messi Masterclass On Display As Barcelona Thra...\n",
566
+ "1395 1997 Are you under constant pressure to connect use...\n",
567
+ "1396 1998 Shun Ethnic Prejudice , Religious Intolerance ...\n",
568
+ "1397 2000 Encrypted On-Prem Connections to Public Clouds..."
569
+ ]
570
+ },
571
+ "execution_count": 45,
572
+ "metadata": {},
573
+ "output_type": "execute_result"
574
+ }
575
+ ],
576
+ "source": [
577
+ "df.tail(20)"
578
+ ]
579
+ },
580
+ {
581
+ "cell_type": "code",
582
+ "execution_count": 46,
583
+ "metadata": {},
584
+ "outputs": [],
585
+ "source": [
586
+ "# Now there is a folder named images containing {id}.jpg files for each id in the dataset (i.e. 1.jpg, 2.jpg, etc.). \n",
587
+ "# create a dataset containing the image itself and the normalized content text for each id. export to parquet file\n",
588
+ "\n",
589
+ "# convert each image into bytes array and store in a new column\n",
590
+ "\n",
591
+ "def convert_to_bytes(img_path):\n",
592
+ " dict = {\"bytes\": [], \"path\": None}\n",
593
+ " with open(img_path, 'rb') as f:\n",
594
+ " img_bytes = f.read()\n",
595
+ "\n",
596
+ " dict = {\"bytes\": [], \"path\": None}\n",
597
+ " dict[\"bytes\"] = img_bytes\n",
598
+ " return dict\n",
599
+ "\n",
600
+ "\n",
601
+ "# create a new column containing the image bytes and store in this format # {\"bytes\": [255,216,2....,34], \"path\": null}\n",
602
+ "df['image'] = df['id'].apply(lambda x: convert_to_bytes('images/' + str(x) + '.jpg'))\n",
603
+ "\n",
604
+ "\n",
605
+ "# drop the id column\n",
606
+ "df = df.drop(columns=['id'])\n",
607
+ "\n",
608
+ "# export to parquet file\n",
609
+ "df.to_parquet('2000_tweet_image_caption.parquet')\n",
610
+ "\n",
611
+ "\n",
612
+ "\n",
613
+ "\n",
614
+ "\n"
615
+ ]
616
+ }
617
+ ],
618
+ "metadata": {
619
+ "kernelspec": {
620
+ "display_name": "Python 3",
621
+ "language": "python",
622
+ "name": "python3"
623
+ },
624
+ "language_info": {
625
+ "codemirror_mode": {
626
+ "name": "ipython",
627
+ "version": 3
628
+ },
629
+ "file_extension": ".py",
630
+ "mimetype": "text/x-python",
631
+ "name": "python",
632
+ "nbconvert_exporter": "python",
633
+ "pygments_lexer": "ipython3",
634
+ "version": "3.11.4"
635
+ }
636
+ },
637
+ "nbformat": 4,
638
+ "nbformat_minor": 2
639
+ }