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

I have found a solution to this question but I am getting error. Can someone help me with the problem?

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

10-9 How have social technologies changed e-commerce?

Answered: 1 week ago