get_movie_dict() takes a 2-D list similar to movie_db and a dictionary similar to ratings as the parameters and returns a dictionary, where each {key: value} of this dictionary is {a valid movie id: a list containing the name of the movie, the year it got released, and the average rating of this movie}. I will refer to this dictionary as movies. >>> movies = get_movie_dict(movies_db, ratings) >>> display_dict(movies) 1: ['Toy Story', 1995, 3.92] 2: ['Jumanji', 1995, 3.43] 3: ['Grumpier Old Men', 1995, 3.26] 4: ['Waiting to Exhale', 1995, 2.36] 5: ['Father of the Bride Part II', 1995, 3.07] 6: ['Heat', 1995, 3.95] 7: ['Sabrina', 1995, 3.19] 8: ['Tom and Huck', 1995, 2.88] 9: ['Sudden Death', 1995, 3.12] 10: ['GoldenEye', 1995, 3.5] 11: ['American President The', 1995, 3.67] 12: ['Dracula: Dead and Loving It', 1995, 2.42] 13: ['Balto', 1995, 3.12] 14: ['Nixon', 1995, 3.83] 15: ['Cutthroat Island', 1995, 3.0] 16: ['Casino', 1995, 3.93] 17: ['Sense and Sensibility', 1995, 3.78] 18: ['Four Rooms', 1995, 3.7] 19: ['Ace Ventura: When Nature Calls', 1995, 2.73] 20: ['Money Train', 1995, 2.5] Add the following function to your module to display the results of the user’s queries. This is movie.csv file movieId title genres 1 Toy Story (1995) Adventure|Animation|Children|Comedy|Fantasy 2 Jumanji (1995) Adventure|Children|Fantasy 3 Grumpier Old Men (1995) Comedy|Romance 4 Waiting to Exhale (1995) Comedy|Drama|Romance 5 Father of the Bride Part II (1995) Comedy 6 Heat (1995) Action|Crime|Thriller 7 Sabrina (1995) Comedy|Romance 8 Tom and Huck (1995) Adventure|Children 9 Sudden Death (1995) Action 10 GoldenEye (1995) Action|Adventure|Thriller 11 American President The (1995) Comedy|Drama|Romance 12 Dracula: Dead and Loving It (1995) Comedy|Horror 13 Balto (1995) Adventure|Animation|Children 14 Nixon (1995) Drama 15 Cutthroat Island (1995) Action|Adventure|Romance 16 Casino (1995) Crime|Drama 17 Sense and Sensibility (1995) Drama|Romance 18 Four Rooms (1995) Comedy 19 Ace Ventura: When Nature Calls (1995) Comedy 20 Money Train (1995) Action|Comedy|Crime|Drama|Thriller
get_movie_dict() takes a 2-D list similar to movie_db and a dictionary similar to ratings as the parameters and returns a dictionary, where each {key: value} of this dictionary is {a valid movie id: a list containing the name of the movie, the year it got released, and the average rating of this movie}. I will refer to this dictionary as movies.
>>> movies = get_movie_dict(movies_db, ratings)
>>> display_dict(movies)
1: ['Toy Story', 1995, 3.92]
2: ['Jumanji', 1995, 3.43]
3: ['Grumpier Old Men', 1995, 3.26]
4: ['Waiting to Exhale', 1995, 2.36]
5: ['Father of the Bride Part II', 1995, 3.07]
6: ['Heat', 1995, 3.95]
7: ['Sabrina', 1995, 3.19]
8: ['Tom and Huck', 1995, 2.88]
9: ['Sudden Death', 1995, 3.12]
10: ['GoldenEye', 1995, 3.5]
11: ['American President The', 1995, 3.67]
12: ['Dracula: Dead and Loving It', 1995, 2.42]
13: ['Balto', 1995, 3.12]
14: ['Nixon', 1995, 3.83]
15: ['Cutthroat Island', 1995, 3.0]
16: ['Casino', 1995, 3.93]
17: ['Sense and Sensibility', 1995, 3.78]
18: ['Four Rooms', 1995, 3.7]
19: ['Ace Ventura: When Nature Calls', 1995, 2.73]
20: ['Money Train', 1995, 2.5]
Add the following function to your module to display the results of the user’s queries.
This is movie.csv file
movieId | title | genres |
1 | Toy Story (1995) | Adventure|Animation|Children|Comedy|Fantasy |
2 | Jumanji (1995) | Adventure|Children|Fantasy |
3 | Grumpier Old Men (1995) | Comedy|Romance |
4 | Waiting to Exhale (1995) | Comedy|Drama|Romance |
5 | Father of the Bride Part II (1995) | Comedy |
6 | Heat (1995) | Action|Crime|Thriller |
7 | Sabrina (1995) | Comedy|Romance |
8 | Tom and Huck (1995) | Adventure|Children |
9 | Sudden Death (1995) | Action |
10 | GoldenEye (1995) | Action|Adventure|Thriller |
11 | American President The (1995) | Comedy|Drama|Romance |
12 | Dracula: Dead and Loving It (1995) | Comedy|Horror |
13 | Balto (1995) | Adventure|Animation|Children |
14 | Nixon (1995) | Drama |
15 | Cutthroat Island (1995) | Action|Adventure|Romance |
16 | Casino (1995) | Crime|Drama |
17 | Sense and Sensibility (1995) | Drama|Romance |
18 | Four Rooms (1995) | Comedy |
19 | Ace Ventura: When Nature Calls (1995) | Comedy |
20 | Money Train (1995) | Action|Comedy|Crime|Drama|Thriller |
Step by step
Solved in 4 steps with 2 images