Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 7 . 3 . Create a new DataFrame, called disney, by setting the index of disney _ movies to 'movie _ title'. Don't change

Question 7.3. Create a new DataFrame, called disney, by setting the index of disney_movies to 'movie_title'. Don't change disney_movies.
disney = disney_movies.set_index('movie_title')
disney
genre MPAA_rating year total_gross_millions adjusted_gross_millions
movie_title
Snow White and the Seven Dwarfs Musical G 1937184.9254855228.953251
Pinocchio Adventure G 194084.3000002188.229052
Fantasia Musical G 194083.3200002187.090808
Song of the South Adventure G 194665.0000001078.510579
Cinderella (1950) Drama G 195085.000000920.608730
..................
The Light Between Oceans Drama PG-13201612.54597912.545979
Queen of Katwe Drama PG 20168.8743898.874389
Doctor Strange Adventure PG-132016232.532923232.532923
Moana Adventure PG 2016246.082029246.082029
Rogue One: A Star Wars Story Adventure PG-132016529.483936529.483936
579 rows \times 5 columns
grader.check("q7_3")
q7_3 passed!
You should think about why we've chosen to set the index to 'movie_title', instead of any other column.
Question 7.4. Time for some movie trivia! What genre is the movie 'Finding Nemo' and in what year was it released? Assign your answers to nemo_genre, which should be a string, and nemo_year, which should be an int.
Don't type in the answers by hand; get Python to extract this information for you.
year
nemo_genre = disney.get('genre').loc['Finding Nemo']
nemo_year = disney.get('year').loc['Finding Nemo']
# Don't change the lines below.
print('Genre', nemo_genre)
print('Year:', nemo_year)
Genre Adventure
Year: 2003
grader.check("q7_4")
q7_4 passed!
Question 7.5. Disney has produced many successful films over the years. Find the number of movies with an adjusted box office revenue of over 100 million dollars. Assign your answer to disney_100m.
(
disney_100m =(disney.get('adjusted_gross_millions')>100).sum()
disney_100m
179
grader.check("q7_5")
q7_5 passed!
Question 7.6. Assign fifth_highest_revenue to the fifth-highest value of adjusted_gross_millions. Assign fifth_highest_name to the name of the movie with the fifth-highest adjusted revenue.
Again, don't type in these values by hand; get Python to extract this information for you.
Note: Remember that you can perform intermediate steps by adding new cells above the provided ones, or by adding in additional lines of code.
fifth_highest_revenue =...
fifth_highest_name =...
# Don't change the lines below.
print('Revenue:', fifth_highest_revenue, 'million dollars')
print('Name:', fifth_highest_name)
grader.check("q7_6")
Question 7.7. Disney is known for making movies for children, many of which are rated G for "general audiences". Let's see how much money Disney has earned in total across all of its G-rated movies. Find the sum of the total_gross_millions column for G-rated movies only, and assign your answer to g_revenue.
g_revenue =...
g_revenue
grader.check("q7_7")
Question 7.8. Finally, let's see which genres are most popular by seeing how much money movies from each genre earn on average. Create a DataFrame called revenue_by_genre that is indexed by genre and contains just one column, called adjusted_gross_millions, which contains the average adjusted box office revenue of all movies from a given genre. Order the rows of revenue_by_genre in descending order of adjusted_gross_millions to see what genres Disney does best!
Hint: Our solution for this question used only one line of code (thanks, groupby)!

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_2

Step: 3

blur-text-image_3

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

Recognize the power of service guarantees.

Answered: 1 week ago

Question

What are the best practices for managing a large software project?

Answered: 1 week ago

Question

How does clustering in unsupervised learning help in data analysis?

Answered: 1 week ago