Answered step by step
Verified Expert Solution
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 Create a new DataFrame, called disney, by setting the index of disneymovies to 'movietitle'. Don't change disneymovies.
disney disneymovies.setindexmovietitle'
disney
genre MPAArating year totalgrossmillions adjustedgrossmillions
movietitle
Snow White and the Seven Dwarfs Musical G
Pinocchio Adventure G
Fantasia Musical G
Song of the South Adventure G
Cinderella Drama G
The Light Between Oceans Drama PG
Queen of Katwe Drama PG
Doctor Strange Adventure PG
Moana Adventure PG
Rogue One: A Star Wars Story Adventure PG
rows times columns
grader.checkq
q passed!
You should think about why we've chosen to set the index to 'movietitle', instead of any other column.
Question Time for some movie trivia! What genre is the movie 'Finding Nemo' and in what year was it released? Assign your answers to nemogenre, which should be a string, and nemoyear, which should be an int.
Don't type in the answers by hand; get Python to extract this information for you.
year
nemogenre disney.getgenrelocFinding Nemo'
nemoyear disney.getyearlocFinding Nemo'
# Don't change the lines below.
printGenre nemogenre
printYear: nemoyear
Genre Adventure
Year:
grader.checkq
q passed!
Question Disney has produced many successful films over the years. Find the number of movies with an adjusted box office revenue of over million dollars. Assign your answer to disneym
disneym disneygetadjustedgrossmillions'sum
disneym
grader.checkq
q passed!
Question Assign fifthhighestrevenue to the fifthhighest value of adjustedgrossmillions. Assign fifthhighestname to the name of the movie with the fifthhighest 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.
fifthhighestrevenue
fifthhighestname
# Don't change the lines below.
printRevenue: fifthhighestrevenue, 'million dollars'
printName: fifthhighestname
grader.checkq
Question 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 Grated movies. Find the sum of the totalgrossmillions column for Grated movies only, and assign your answer to grevenue.
grevenue
grevenue
grader.checkq
Question 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 revenuebygenre that is indexed by genre and contains just one column, called adjustedgrossmillions, which contains the average adjusted box office revenue of all movies from a given genre. Order the rows of revenuebygenre in descending order of adjustedgrossmillions 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started