File size: 30,561 Bytes
45a5c11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#! pip install -r ../requirements.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "movies_path = '../data/standard/movies_m10_rich'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "links = pd.read_csv('../data/standard/links.csv', index_col='movieId') # ids do filme y nas plataformas imdb e tmdb, util para enriquecer os dados\n",
    "movies = pd.read_csv(movies_path+'.csv', index_col='movieId') # dados do filme y\n",
    "ratings = pd.read_csv('../data/reduced/ratings_m10.csv', index_col='movieId') # avaliacao do usuario x pro filme y\n",
    "tags = pd.read_csv('../data/standard/tags.csv', index_col='movieId') # n parece mto relevante"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## separação do ano de lançamento"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "movies[['title', 'year']] = movies['title'].str.extract('(.+)+\\((\\d+)', expand=True)\n",
    "\n",
    "movies.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "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>tmdbId</th>\n",
       "      <th>imdbId</th>\n",
       "      <th>cast</th>\n",
       "      <th>director</th>\n",
       "      <th>keywords</th>\n",
       "      <th>overview</th>\n",
       "      <th>title</th>\n",
       "      <th>genres</th>\n",
       "      <th>year</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>movieId</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>117529</th>\n",
       "      <td>135397</td>\n",
       "      <td>369610</td>\n",
       "      <td>Chris Pratt|Bryce Dallas Howard|Irrfan Khan|Vi...</td>\n",
       "      <td>Colin Trevorrow</td>\n",
       "      <td>monster|dna|tyrannosaurus rex|velociraptor|island</td>\n",
       "      <td>Twenty-two years after the events of Jurassic ...</td>\n",
       "      <td>Jurassic World</td>\n",
       "      <td>Action|Adventure|Drama|Sci-Fi|Thriller</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122882</th>\n",
       "      <td>76341</td>\n",
       "      <td>1392190</td>\n",
       "      <td>Tom Hardy|Charlize Theron|Hugh Keays-Byrne|Nic...</td>\n",
       "      <td>George Miller</td>\n",
       "      <td>future|chase|post-apocalyptic|dystopia|australia</td>\n",
       "      <td>An apocalyptic story set in the furthest reach...</td>\n",
       "      <td>Mad Max: Fury Road</td>\n",
       "      <td>Action|Adventure|Sci-Fi|Thriller</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122886</th>\n",
       "      <td>140607</td>\n",
       "      <td>2488496</td>\n",
       "      <td>Harrison Ford|Mark Hamill|Carrie Fisher|Adam D...</td>\n",
       "      <td>J.J. Abrams</td>\n",
       "      <td>android|spaceship|jedi|space opera|3d</td>\n",
       "      <td>Thirty years after defeating the Galactic Empi...</td>\n",
       "      <td>Star Wars: Episode VII - The Force Awakens</td>\n",
       "      <td>Action|Adventure|Fantasy|Sci-Fi|IMAX</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>139385</th>\n",
       "      <td>281957</td>\n",
       "      <td>1663202</td>\n",
       "      <td>Leonardo DiCaprio|Tom Hardy|Will Poulter|Domhn...</td>\n",
       "      <td>Alejandro González Iñárritu</td>\n",
       "      <td>father-son relationship|rape|based on novel|mo...</td>\n",
       "      <td>In the 1820s, a frontiersman, Hugh Glass, sets...</td>\n",
       "      <td>The Revenant</td>\n",
       "      <td>Adventure|Drama</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134130</th>\n",
       "      <td>286217</td>\n",
       "      <td>3659388</td>\n",
       "      <td>Matt Damon|Jessica Chastain|Kristen Wiig|Jeff ...</td>\n",
       "      <td>Ridley Scott</td>\n",
       "      <td>based on novel|mars|nasa|isolation|botanist</td>\n",
       "      <td>During a manned mission to Mars, Astronaut Mar...</td>\n",
       "      <td>The Martian</td>\n",
       "      <td>Adventure|Drama|Sci-Fi</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         tmdbId   imdbId                                               cast  \\\n",
       "movieId                                                                       \n",
       "117529   135397   369610  Chris Pratt|Bryce Dallas Howard|Irrfan Khan|Vi...   \n",
       "122882    76341  1392190  Tom Hardy|Charlize Theron|Hugh Keays-Byrne|Nic...   \n",
       "122886   140607  2488496  Harrison Ford|Mark Hamill|Carrie Fisher|Adam D...   \n",
       "139385   281957  1663202  Leonardo DiCaprio|Tom Hardy|Will Poulter|Domhn...   \n",
       "134130   286217  3659388  Matt Damon|Jessica Chastain|Kristen Wiig|Jeff ...   \n",
       "\n",
       "                               director  \\\n",
       "movieId                                   \n",
       "117529                  Colin Trevorrow   \n",
       "122882                    George Miller   \n",
       "122886                      J.J. Abrams   \n",
       "139385   Alejandro González Iñárritu   \n",
       "134130                     Ridley Scott   \n",
       "\n",
       "                                                  keywords  \\\n",
       "movieId                                                      \n",
       "117529   monster|dna|tyrannosaurus rex|velociraptor|island   \n",
       "122882    future|chase|post-apocalyptic|dystopia|australia   \n",
       "122886               android|spaceship|jedi|space opera|3d   \n",
       "139385   father-son relationship|rape|based on novel|mo...   \n",
       "134130         based on novel|mars|nasa|isolation|botanist   \n",
       "\n",
       "                                                  overview  \\\n",
       "movieId                                                      \n",
       "117529   Twenty-two years after the events of Jurassic ...   \n",
       "122882   An apocalyptic story set in the furthest reach...   \n",
       "122886   Thirty years after defeating the Galactic Empi...   \n",
       "139385   In the 1820s, a frontiersman, Hugh Glass, sets...   \n",
       "134130   During a manned mission to Mars, Astronaut Mar...   \n",
       "\n",
       "                                               title  \\\n",
       "movieId                                                \n",
       "117529                               Jurassic World    \n",
       "122882                           Mad Max: Fury Road    \n",
       "122886   Star Wars: Episode VII - The Force Awakens    \n",
       "139385                                 The Revenant    \n",
       "134130                                  The Martian    \n",
       "\n",
       "                                         genres  year  \n",
       "movieId                                                \n",
       "117529   Action|Adventure|Drama|Sci-Fi|Thriller  2015  \n",
       "122882         Action|Adventure|Sci-Fi|Thriller  2015  \n",
       "122886     Action|Adventure|Fantasy|Sci-Fi|IMAX  2015  \n",
       "139385                          Adventure|Drama  2015  \n",
       "134130                   Adventure|Drama|Sci-Fi  2015  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "genres = movies['genres']\n",
    "cast = movies['cast']\n",
    "keywords = movies['keywords']\n",
    "\n",
    "def split_into_list(series):\n",
    "    return str(series).split('|') \n",
    "\n",
    "genres = genres.apply(split_into_list)\n",
    "cast = cast.apply(split_into_list)\n",
    "keywords = keywords.apply(split_into_list)\n",
    "\n",
    "\n",
    "movies['genres'] = genres\n",
    "movies['cast'] = cast\n",
    "movies['keywords'] = keywords"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "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>tmdbId</th>\n",
       "      <th>imdbId</th>\n",
       "      <th>cast</th>\n",
       "      <th>director</th>\n",
       "      <th>keywords</th>\n",
       "      <th>overview</th>\n",
       "      <th>title</th>\n",
       "      <th>genres</th>\n",
       "      <th>year</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>movieId</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>117529</th>\n",
       "      <td>135397</td>\n",
       "      <td>369610</td>\n",
       "      <td>[Chris Pratt, Bryce Dallas Howard, Irrfan Khan...</td>\n",
       "      <td>Colin Trevorrow</td>\n",
       "      <td>[monster, dna, tyrannosaurus rex, velociraptor...</td>\n",
       "      <td>Twenty-two years after the events of Jurassic ...</td>\n",
       "      <td>Jurassic World</td>\n",
       "      <td>[Action, Adventure, Drama, Sci-Fi, Thriller]</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122882</th>\n",
       "      <td>76341</td>\n",
       "      <td>1392190</td>\n",
       "      <td>[Tom Hardy, Charlize Theron, Hugh Keays-Byrne,...</td>\n",
       "      <td>George Miller</td>\n",
       "      <td>[future, chase, post-apocalyptic, dystopia, au...</td>\n",
       "      <td>An apocalyptic story set in the furthest reach...</td>\n",
       "      <td>Mad Max: Fury Road</td>\n",
       "      <td>[Action, Adventure, Sci-Fi, Thriller]</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122886</th>\n",
       "      <td>140607</td>\n",
       "      <td>2488496</td>\n",
       "      <td>[Harrison Ford, Mark Hamill, Carrie Fisher, Ad...</td>\n",
       "      <td>J.J. Abrams</td>\n",
       "      <td>[android, spaceship, jedi, space opera, 3d]</td>\n",
       "      <td>Thirty years after defeating the Galactic Empi...</td>\n",
       "      <td>Star Wars: Episode VII - The Force Awakens</td>\n",
       "      <td>[Action, Adventure, Fantasy, Sci-Fi, IMAX]</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>139385</th>\n",
       "      <td>281957</td>\n",
       "      <td>1663202</td>\n",
       "      <td>[Leonardo DiCaprio, Tom Hardy, Will Poulter, D...</td>\n",
       "      <td>Alejandro González Iñárritu</td>\n",
       "      <td>[father-son relationship, rape, based on novel...</td>\n",
       "      <td>In the 1820s, a frontiersman, Hugh Glass, sets...</td>\n",
       "      <td>The Revenant</td>\n",
       "      <td>[Adventure, Drama]</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134130</th>\n",
       "      <td>286217</td>\n",
       "      <td>3659388</td>\n",
       "      <td>[Matt Damon, Jessica Chastain, Kristen Wiig, J...</td>\n",
       "      <td>Ridley Scott</td>\n",
       "      <td>[based on novel, mars, nasa, isolation, botanist]</td>\n",
       "      <td>During a manned mission to Mars, Astronaut Mar...</td>\n",
       "      <td>The Martian</td>\n",
       "      <td>[Adventure, Drama, Sci-Fi]</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         tmdbId   imdbId                                               cast  \\\n",
       "movieId                                                                       \n",
       "117529   135397   369610  [Chris Pratt, Bryce Dallas Howard, Irrfan Khan...   \n",
       "122882    76341  1392190  [Tom Hardy, Charlize Theron, Hugh Keays-Byrne,...   \n",
       "122886   140607  2488496  [Harrison Ford, Mark Hamill, Carrie Fisher, Ad...   \n",
       "139385   281957  1663202  [Leonardo DiCaprio, Tom Hardy, Will Poulter, D...   \n",
       "134130   286217  3659388  [Matt Damon, Jessica Chastain, Kristen Wiig, J...   \n",
       "\n",
       "                               director  \\\n",
       "movieId                                   \n",
       "117529                  Colin Trevorrow   \n",
       "122882                    George Miller   \n",
       "122886                      J.J. Abrams   \n",
       "139385   Alejandro González Iñárritu   \n",
       "134130                     Ridley Scott   \n",
       "\n",
       "                                                  keywords  \\\n",
       "movieId                                                      \n",
       "117529   [monster, dna, tyrannosaurus rex, velociraptor...   \n",
       "122882   [future, chase, post-apocalyptic, dystopia, au...   \n",
       "122886         [android, spaceship, jedi, space opera, 3d]   \n",
       "139385   [father-son relationship, rape, based on novel...   \n",
       "134130   [based on novel, mars, nasa, isolation, botanist]   \n",
       "\n",
       "                                                  overview  \\\n",
       "movieId                                                      \n",
       "117529   Twenty-two years after the events of Jurassic ...   \n",
       "122882   An apocalyptic story set in the furthest reach...   \n",
       "122886   Thirty years after defeating the Galactic Empi...   \n",
       "139385   In the 1820s, a frontiersman, Hugh Glass, sets...   \n",
       "134130   During a manned mission to Mars, Astronaut Mar...   \n",
       "\n",
       "                                               title  \\\n",
       "movieId                                                \n",
       "117529                               Jurassic World    \n",
       "122882                           Mad Max: Fury Road    \n",
       "122886   Star Wars: Episode VII - The Force Awakens    \n",
       "139385                                 The Revenant    \n",
       "134130                                  The Martian    \n",
       "\n",
       "                                               genres  year  \n",
       "movieId                                                      \n",
       "117529   [Action, Adventure, Drama, Sci-Fi, Thriller]  2015  \n",
       "122882          [Action, Adventure, Sci-Fi, Thriller]  2015  \n",
       "122886     [Action, Adventure, Fantasy, Sci-Fi, IMAX]  2015  \n",
       "139385                             [Adventure, Drama]  2015  \n",
       "134130                     [Adventure, Drama, Sci-Fi]  2015  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "movies = movies.sort_index()\n",
    "movies.index = [i+1 for i in range(len(movies.index.values))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "movies['movieId'] = movies.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "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>tmdbId</th>\n",
       "      <th>imdbId</th>\n",
       "      <th>cast</th>\n",
       "      <th>director</th>\n",
       "      <th>keywords</th>\n",
       "      <th>overview</th>\n",
       "      <th>title</th>\n",
       "      <th>genres</th>\n",
       "      <th>year</th>\n",
       "      <th>movieId</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>862</td>\n",
       "      <td>114709</td>\n",
       "      <td>[Tom Hanks, Tim Allen, Don Rickles, Jim Varney...</td>\n",
       "      <td>John Lasseter</td>\n",
       "      <td>[jealousy, toy, boy, friendship, friends]</td>\n",
       "      <td>Woody the cowboy is young Andy’s favorite to...</td>\n",
       "      <td>Toy Story</td>\n",
       "      <td>[Adventure, Animation, Children, Comedy, Fantasy]</td>\n",
       "      <td>1995</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>8844</td>\n",
       "      <td>113497</td>\n",
       "      <td>[Robin Williams, Jonathan Hyde, Kirsten Dunst,...</td>\n",
       "      <td>Joe Johnston</td>\n",
       "      <td>[board game, disappearance, based on a childre...</td>\n",
       "      <td>When siblings Judy and Peter discover an encha...</td>\n",
       "      <td>Jumanji</td>\n",
       "      <td>[Adventure, Children, Fantasy]</td>\n",
       "      <td>1995</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>15602</td>\n",
       "      <td>113228</td>\n",
       "      <td>[Walter Matthau, Jack Lemmon, Ann-Margret, Sop...</td>\n",
       "      <td>Howard Deutch</td>\n",
       "      <td>[fishing, best friend, duringcreditsstinger, o...</td>\n",
       "      <td>A family wedding reignites the ancient feud be...</td>\n",
       "      <td>Grumpier Old Men</td>\n",
       "      <td>[Comedy, Romance]</td>\n",
       "      <td>1995</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>11862</td>\n",
       "      <td>113041</td>\n",
       "      <td>[Steve Martin, Diane Keaton, Martin Short, Kim...</td>\n",
       "      <td>Charles Shyer</td>\n",
       "      <td>[baby, midlife crisis, confidence, aging, daug...</td>\n",
       "      <td>Just when George Banks has recovered from his ...</td>\n",
       "      <td>Father of the Bride Part II</td>\n",
       "      <td>[Comedy]</td>\n",
       "      <td>1995</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>949</td>\n",
       "      <td>113277</td>\n",
       "      <td>[Al Pacino, Robert De Niro, Val Kilmer, Jon Vo...</td>\n",
       "      <td>Michael Mann</td>\n",
       "      <td>[gambling, suicide attempt, burglar, booties, ...</td>\n",
       "      <td>Obsessive master thief, Neil McCauley leads a ...</td>\n",
       "      <td>Heat</td>\n",
       "      <td>[Action, Crime, Thriller]</td>\n",
       "      <td>1995</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",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022</th>\n",
       "      <td>281957</td>\n",
       "      <td>1663202</td>\n",
       "      <td>[Leonardo DiCaprio, Tom Hardy, Will Poulter, D...</td>\n",
       "      <td>Alejandro González Iñárritu</td>\n",
       "      <td>[father-son relationship, rape, based on novel...</td>\n",
       "      <td>In the 1820s, a frontiersman, Hugh Glass, sets...</td>\n",
       "      <td>The Revenant</td>\n",
       "      <td>[Adventure, Drama]</td>\n",
       "      <td>2015</td>\n",
       "      <td>2022</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023</th>\n",
       "      <td>273481</td>\n",
       "      <td>3397884</td>\n",
       "      <td>[Emily Blunt, Benicio del Toro, Josh Brolin, V...</td>\n",
       "      <td>Denis Villeneuve</td>\n",
       "      <td>[mexico, cia, smoking, texas, fbi]</td>\n",
       "      <td>A young female FBI agent joins a secret CIA op...</td>\n",
       "      <td>Sicario</td>\n",
       "      <td>[Crime, Drama, Mystery]</td>\n",
       "      <td>2015</td>\n",
       "      <td>2023</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2024</th>\n",
       "      <td>257211</td>\n",
       "      <td>2361509</td>\n",
       "      <td>[Robert De Niro, Anne Hathaway, Rene Russo, An...</td>\n",
       "      <td>Nancy Meyers</td>\n",
       "      <td>[intern, woman director]</td>\n",
       "      <td>70-year-old widower Ben Whittaker has discover...</td>\n",
       "      <td>The Intern</td>\n",
       "      <td>[Comedy]</td>\n",
       "      <td>2015</td>\n",
       "      <td>2024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025</th>\n",
       "      <td>314365</td>\n",
       "      <td>1895587</td>\n",
       "      <td>[Mark Ruffalo, Michael Keaton, Rachel McAdams,...</td>\n",
       "      <td>Tom McCarthy</td>\n",
       "      <td>[child abuse, journalism, judge, florida, boston]</td>\n",
       "      <td>The true story of how The Boston Globe uncover...</td>\n",
       "      <td>Spotlight</td>\n",
       "      <td>[Thriller]</td>\n",
       "      <td>2015</td>\n",
       "      <td>2025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2026</th>\n",
       "      <td>318846</td>\n",
       "      <td>1596363</td>\n",
       "      <td>[Christian Bale, Steve Carell, Ryan Gosling, B...</td>\n",
       "      <td>Adam McKay</td>\n",
       "      <td>[bank, fraud, biography, wall street, finances]</td>\n",
       "      <td>The men who made millions from a global econom...</td>\n",
       "      <td>Big Short, The</td>\n",
       "      <td>[Drama]</td>\n",
       "      <td>2015</td>\n",
       "      <td>2026</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2026 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      tmdbId   imdbId                                               cast  \\\n",
       "1        862   114709  [Tom Hanks, Tim Allen, Don Rickles, Jim Varney...   \n",
       "2       8844   113497  [Robin Williams, Jonathan Hyde, Kirsten Dunst,...   \n",
       "3      15602   113228  [Walter Matthau, Jack Lemmon, Ann-Margret, Sop...   \n",
       "4      11862   113041  [Steve Martin, Diane Keaton, Martin Short, Kim...   \n",
       "5        949   113277  [Al Pacino, Robert De Niro, Val Kilmer, Jon Vo...   \n",
       "...      ...      ...                                                ...   \n",
       "2022  281957  1663202  [Leonardo DiCaprio, Tom Hardy, Will Poulter, D...   \n",
       "2023  273481  3397884  [Emily Blunt, Benicio del Toro, Josh Brolin, V...   \n",
       "2024  257211  2361509  [Robert De Niro, Anne Hathaway, Rene Russo, An...   \n",
       "2025  314365  1895587  [Mark Ruffalo, Michael Keaton, Rachel McAdams,...   \n",
       "2026  318846  1596363  [Christian Bale, Steve Carell, Ryan Gosling, B...   \n",
       "\n",
       "                            director  \\\n",
       "1                      John Lasseter   \n",
       "2                       Joe Johnston   \n",
       "3                      Howard Deutch   \n",
       "4                      Charles Shyer   \n",
       "5                       Michael Mann   \n",
       "...                              ...   \n",
       "2022  Alejandro González Iñárritu   \n",
       "2023                Denis Villeneuve   \n",
       "2024                    Nancy Meyers   \n",
       "2025                    Tom McCarthy   \n",
       "2026                      Adam McKay   \n",
       "\n",
       "                                               keywords  \\\n",
       "1             [jealousy, toy, boy, friendship, friends]   \n",
       "2     [board game, disappearance, based on a childre...   \n",
       "3     [fishing, best friend, duringcreditsstinger, o...   \n",
       "4     [baby, midlife crisis, confidence, aging, daug...   \n",
       "5     [gambling, suicide attempt, burglar, booties, ...   \n",
       "...                                                 ...   \n",
       "2022  [father-son relationship, rape, based on novel...   \n",
       "2023                 [mexico, cia, smoking, texas, fbi]   \n",
       "2024                           [intern, woman director]   \n",
       "2025  [child abuse, journalism, judge, florida, boston]   \n",
       "2026    [bank, fraud, biography, wall street, finances]   \n",
       "\n",
       "                                               overview  \\\n",
       "1     Woody the cowboy is young Andy’s favorite to...   \n",
       "2     When siblings Judy and Peter discover an encha...   \n",
       "3     A family wedding reignites the ancient feud be...   \n",
       "4     Just when George Banks has recovered from his ...   \n",
       "5     Obsessive master thief, Neil McCauley leads a ...   \n",
       "...                                                 ...   \n",
       "2022  In the 1820s, a frontiersman, Hugh Glass, sets...   \n",
       "2023  A young female FBI agent joins a secret CIA op...   \n",
       "2024  70-year-old widower Ben Whittaker has discover...   \n",
       "2025  The true story of how The Boston Globe uncover...   \n",
       "2026  The men who made millions from a global econom...   \n",
       "\n",
       "                             title  \\\n",
       "1                       Toy Story    \n",
       "2                         Jumanji    \n",
       "3                Grumpier Old Men    \n",
       "4     Father of the Bride Part II    \n",
       "5                            Heat    \n",
       "...                            ...   \n",
       "2022                 The Revenant    \n",
       "2023                      Sicario    \n",
       "2024                   The Intern    \n",
       "2025                    Spotlight    \n",
       "2026               Big Short, The    \n",
       "\n",
       "                                                 genres  year  movieId  \n",
       "1     [Adventure, Animation, Children, Comedy, Fantasy]  1995        1  \n",
       "2                        [Adventure, Children, Fantasy]  1995        2  \n",
       "3                                     [Comedy, Romance]  1995        3  \n",
       "4                                              [Comedy]  1995        4  \n",
       "5                             [Action, Crime, Thriller]  1995        5  \n",
       "...                                                 ...   ...      ...  \n",
       "2022                                 [Adventure, Drama]  2015     2022  \n",
       "2023                            [Crime, Drama, Mystery]  2015     2023  \n",
       "2024                                           [Comedy]  2015     2024  \n",
       "2025                                         [Thriller]  2015     2025  \n",
       "2026                                            [Drama]  2015     2026  \n",
       "\n",
       "[2026 rows x 10 columns]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "movies.to_csv(movies_path+'_pre.csv')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}