Q5: Save all of this director's movies and their ratings in a variable called all_movies_ratings, then print this variable. (The director with the most movies you got from the last question.) # your code here all_movies_ratings = all_movies_ratings[['movie_title', 'imdb_score']] #this will select this columns only df['movie_title'] = df['movie_title'].str.replace('Ê','') print("\nQUESTION 5:") print(all_movies_ratings) Q6: Recommend a **random** movie that has a rating of over 8.3. Store the random recommendation in a variable called "rand_goodmovie". What is the title and imdb_score of your recommendation? Here are the steps: 1. Query the data ('df' DataFrame) for movies with a rating over 8.3 (imdb_score > 8.3) 2. Create a random integer index location to get a single movie recommendation 3. Save the random movie recommendation in a DataFrame called 'rand_goodmovie' 4. Save the title of the random movie recommendation in a variable "random_title" and print it 5. Save the imdb_score of the random movie recommendation in a variable "random_imdb_score" and print it # Do not modify this part, it's needed for grading import random random.seed(0) # your code here all_good_movies = df[df.imdb_score > 8.3] # Query the data ('df' DataFrame) for movies with a rating over 8.3 (imdb_score > 8.3) rand_int = random.randint(0,len(all_good_movies)) #Create a random integer index location to get a single movie recommendation rand_goodmovie = all_good_movies.loc[rand_int] #Save the random movie recommendation in a DataFrame called 'rand_goodmovie' random_title = rand_goodmovie['movie_title'] #Save the title of the random movie recommendation in a variable "random_title" and print it print("\nQUESTION 6:") print("Recommended random movie:\n"+random_title) random_imdb_score = rand_goodmovie['imdb_score'] #Save the imdb_score of the random movie recommendation in a variable "random_imdb_score" and print it print("\nIMDB score: "+str(random_imdb_score))
Q5:
Save all of this director's movies and their ratings in a variable called all_movies_ratings, then print this variable.
(The director with the most movies you got from the last question.)
# your code here
all_movies_ratings = all_movies_ratings[['movie_title', 'imdb_score']] #this will select this columns only
df['movie_title'] = df['movie_title'].str.replace('Ê','')
print("\nQUESTION 5:")
print(all_movies_ratings)
Q6:
Recommend a **random** movie that has a rating of over 8.3.
Store the random recommendation in a variable called "rand_goodmovie".
What is the title and imdb_score of your recommendation?
Here are the steps:
1. Query the data ('df' DataFrame) for movies with a rating over 8.3 (imdb_score > 8.3)
2. Create a random integer index location to get a single movie recommendation
3. Save the random movie recommendation in a DataFrame called 'rand_goodmovie'
4. Save the title of the random movie recommendation in a variable "random_title" and print it
5. Save the imdb_score of the random movie recommendation in a variable "random_imdb_score" and print it
# Do not modify this part, it's needed for grading
import random
random.seed(0)
# your code here
all_good_movies = df[df.imdb_score > 8.3] # Query the data ('df' DataFrame) for movies with a rating over 8.3 (imdb_score > 8.3)
rand_int = random.randint(0,len(all_good_movies)) #Create a random integer index location to get a single movie recommendation
rand_goodmovie = all_good_movies.loc[rand_int] #Save the random movie recommendation in a DataFrame called 'rand_goodmovie'
random_title = rand_goodmovie['movie_title'] #Save the title of the random movie recommendation in a variable "random_title" and print it
print("\nQUESTION 6:")
print("Recommended random movie:\n"+random_title)
random_imdb_score = rand_goodmovie['imdb_score'] #Save the imdb_score of the random movie recommendation in a variable "random_imdb_score" and print it
print("\nIMDB score: "+str(random_imdb_score))
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images