Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We have to obtain a movie id as input from the user . After obtaining the user input how to fetch all movies from the

We have to obtain a movie id as input from the user . After obtaining the user input how to fetch all movies from the database which have at least one genre common with user input and have at least one rating identical to that of one of user input's ratings.(using python pandas dataframe).

eg: if A is the movie id obtained from the user and A has genres "Romantic|Comedy" and has fetched ratings "4.5, 3.0, 2.5", all Romantic or Comedy movie that have obtained at least one rating of 4.5 or 3.0 or 2.5 would be output. There are 2 csv files - movies.csv , ratings.csv which have movie_id as the common column.

movies.csv ----> movie_id, movie_name, genre

ratings.csv ----> movie_id, ratings_given

PS: I HAVE FOUND A SOLUTION FOR THIS QUESTION, IT IS GIVEN BELOW. BUT I AM GETTING AN ERROR. I TRIED TO CORRECT IT BUT ITS NOT HELPING .

THIS IS DONE IN PYTHON PANDAS DATAFRAME. I NEED AN ANSWER IN THE SAME. CAN ANYONE HELP ME OUT WITH THIS?

import pandas as pd

movies = pd.read_csv('movies.csv')

ratings = pd.read_csv('ratings.csv')

movie_id = input()

movie_genres = movies[movies['movie_id'] == movie_id]['genre'].values[0].split('|')

movie_ratings = ratings[ratings['movie_id'] == movie_id]['ratings_given'].values

recommended_movies = movies[movies['genre'].isin(movie_genres) & movies['ratings_given'].isin(movie_ratings)]

print(recommended_movies)

Error is as shown on the image.

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

Simplify the given expressions. If f(x) = 2x x 2 , find (1). a

Answered: 1 week ago

Question

Explain the steps involved in training programmes.

Answered: 1 week ago

Question

What are the need and importance of training ?

Answered: 1 week ago