Statement of Completion#6ae95f80
Intro to Pandas for Data Analysis
medium
Practice Data Filtering & Sorting with Hollywood Movie Data
Resolution
Activities
Practice Data Filtering & Sorting with Hollywood Movie Data¶
Explore¶
Let's explore our dataset
in our lab
In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
In [2]:
df = pd.read_csv('data/movies_dataset.csv', low_memory=False)
In [3]:
df.head()
Out[3]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | GoldenEye | True | 58000000 | Adventure, Action, Thriller | http://www.mgm.com/view/movie/757/Goldeneye/ | 710 | tt0113189 | English | GoldenEye | James Bond must unmask the mysterious head of ... | ... | 130.0 | English, Pусский, Español | Released | No limits. No fears. No substitutes. | False | 6.6 | 1194.0 | United Artists, Eon Productions | 60, 7576 | United Kingdom, United States of America |
1 | Friday | True | 3500000 | Comedy | http://www.newline.com/properties/friday.html | 10634 | tt0113118 | English | Friday | Craig and Smokey are two guys in Los Angeles h... | ... | 91.0 | English | Released | A lot can go down between thursday and saturda... | False | 7.0 | 513.0 | New Line Cinema | 12 | United States of America |
2 | From Dusk Till Dawn | True | 19000000 | Horror, Action, Thriller, Crime | http://www.miramax.com/movie/from-dusk-till-dawn/ | 755 | tt0116367 | English | From Dusk Till Dawn | Seth Gecko and his younger brother Richard are... | ... | 108.0 | English, Español | Released | One night is all that stands between them and ... | False | 6.9 | 1644.0 | A Band Apart, Dimension Films, Los Hooligans P... | 59, 7405, 11705, 53009 | United States of America |
3 | Blue in the Face | True | 2000000 | Comedy | http://miramax.com/movie/blue-in-the-face/ | 5894 | tt0112541 | English | Blue in the Face | Auggie runs a small tobacco shop in Brooklyn, ... | ... | 83.0 | English | Released | Welcome to the planet Brooklyn. | False | 6.8 | 28.0 | Miramax Films, InterAL | 14, 30334 | United States of America |
4 | Mighty Morphin Power Rangers: The Movie | True | 15000000 | Action, Adventure, Science Fiction, Family, Fa... | http://www.powerrangers.com/ | 9070 | tt0113820 | English | Mighty Morphin Power Rangers: The Movie | Power up with six incredible teens who out-man... | ... | 92.0 | English | Released | The Power Is On! | False | 5.2 | 153.0 | Twentieth Century Fox Film Corporation, Saban ... | 306, 2106, 9255 | Japan, United States of America |
5 rows × 24 columns
In [4]:
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 693 entries, 0 to 692 Data columns (total 24 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 title 693 non-null object 1 adult 693 non-null bool 2 budget 693 non-null int64 3 genres 693 non-null object 4 homepage 693 non-null object 5 id 693 non-null int64 6 imdb_id 693 non-null object 7 original_language 693 non-null object 8 original_title 693 non-null object 9 overview 693 non-null object 10 popularity 693 non-null float64 11 poster_path 693 non-null object 12 release_date 693 non-null object 13 revenue 693 non-null float64 14 runtime 693 non-null float64 15 spoken_languages 691 non-null object 16 status 693 non-null object 17 tagline 693 non-null object 18 video 693 non-null bool 19 vote_average 693 non-null float64 20 vote_count 693 non-null float64 21 production_companies_name 662 non-null object 22 production_companies_id 662 non-null object 23 production_countries_name 682 non-null object dtypes: bool(2), float64(5), int64(2), object(15) memory usage: 120.6+ KB
1) Find the movie with the maximum runtime
.¶
In [6]:
# Get the maximum value from the 'runtime' column of the DataFrame 'df'
df['runtime'].max()
Out[6]:
476.0
2) What is the earliest Release Date?¶
In [7]:
# Find the earliest release date from the 'release_date' column
df['release_date'].min()
Out[7]:
'1940-11-13'
3) What's the highest value in the vote_count
column?¶
In [8]:
# Get the maximum vote count
df['vote_count'].max()
Out[8]:
12269.0
4) Select the first 5 movies¶
In [10]:
first_5_movies = df.iloc[:5]
first_5_movies
Out[10]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | GoldenEye | True | 58000000 | Adventure, Action, Thriller | http://www.mgm.com/view/movie/757/Goldeneye/ | 710 | tt0113189 | English | GoldenEye | James Bond must unmask the mysterious head of ... | ... | 130.0 | English, Pусский, Español | Released | No limits. No fears. No substitutes. | False | 6.6 | 1194.0 | United Artists, Eon Productions | 60, 7576 | United Kingdom, United States of America |
1 | Friday | True | 3500000 | Comedy | http://www.newline.com/properties/friday.html | 10634 | tt0113118 | English | Friday | Craig and Smokey are two guys in Los Angeles h... | ... | 91.0 | English | Released | A lot can go down between thursday and saturda... | False | 7.0 | 513.0 | New Line Cinema | 12 | United States of America |
2 | From Dusk Till Dawn | True | 19000000 | Horror, Action, Thriller, Crime | http://www.miramax.com/movie/from-dusk-till-dawn/ | 755 | tt0116367 | English | From Dusk Till Dawn | Seth Gecko and his younger brother Richard are... | ... | 108.0 | English, Español | Released | One night is all that stands between them and ... | False | 6.9 | 1644.0 | A Band Apart, Dimension Films, Los Hooligans P... | 59, 7405, 11705, 53009 | United States of America |
3 | Blue in the Face | True | 2000000 | Comedy | http://miramax.com/movie/blue-in-the-face/ | 5894 | tt0112541 | English | Blue in the Face | Auggie runs a small tobacco shop in Brooklyn, ... | ... | 83.0 | English | Released | Welcome to the planet Brooklyn. | False | 6.8 | 28.0 | Miramax Films, InterAL | 14, 30334 | United States of America |
4 | Mighty Morphin Power Rangers: The Movie | True | 15000000 | Action, Adventure, Science Fiction, Family, Fa... | http://www.powerrangers.com/ | 9070 | tt0113820 | English | Mighty Morphin Power Rangers: The Movie | Power up with six incredible teens who out-man... | ... | 92.0 | English | Released | The Power Is On! | False | 5.2 | 153.0 | Twentieth Century Fox Film Corporation, Saban ... | 306, 2106, 9255 | Japan, United States of America |
5 rows × 24 columns
5) What is the title
of the 10th movie?¶
In [15]:
# Select the row at index 9 from the DataFrame
df.loc[9,'title']
Out[15]:
'Jurassic Park'
6) Select the title
and release_date
of the movies in positions 2nd, 6th and 11th¶
In [18]:
# Select specific rows and columns from the DataFrame 'df'
selected_movies = df.iloc[[1, 5, 10], [0, 12]]
selected_movies
Out[18]:
title | release_date | |
---|---|---|
1 | Friday | 1995-04-26 |
5 | Clerks | 1994-09-13 |
10 | Blade Runner | 1982-06-25 |
7) Sort the df
by release_date
in ascending order.¶
In [20]:
# Sort the DataFrame 'df' by the 'release_date' column in ascending order
df = df.sort_values(by = 'release_date', ascending=True)
8) Select movies in English and sort them by Vote Average¶
In [22]:
# Get English movies sorted by highest rating
df_english_movies = df.loc[df['original_language'] == 'English'].sort_values(by='vote_average', ascending=False)
df_english_movies
Out[22]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
19 | The Godfather | True | 6000000 | Drama, Crime | http://www.thegodfather.com/ | 238 | tt0068646 | English | The Godfather | Spanning the years 1945 to 1955, a chronicle o... | ... | 175.0 | English, Italiano, Latin | Released | An offer you can't refuse. | False | 8.5 | 6024.0 | Paramount Pictures, Alfran Productions | 4, 10211 | United States of America |
237 | The Dark Knight | True | 185000000 | Drama, Action, Crime, Thriller | http://thedarkknight.warnerbros.com/dvdsite/ | 155 | tt0468569 | English | The Dark Knight | Batman raises the stakes in his war on crime. ... | ... | 152.0 | English, 普通话 | Released | Why So Serious? | False | 8.3 | 12269.0 | DC Comics, Legendary Pictures, Warner Bros., D... | 429, 923, 6194, 9993, 9996 | United Kingdom, United States of America |
27 | The Empire Strikes Back | True | 18000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 1891 | tt0080684 | English | The Empire Strikes Back | The epic saga continues as Luke Skywalker, in ... | ... | 124.0 | English | Released | The Adventure Continues... | False | 8.2 | 5998.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
6 | Star Wars | True | 11000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 11 | tt0076759 | English | Star Wars | Princess Leia is captured and held hostage by ... | ... | 121.0 | English | Released | A long time ago in a galaxy far, far away... | False | 8.1 | 6778.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
577 | George Carlin: Life Is Worth Losing | True | 0 | Documentary, Comedy, TV Movie | http://www.georgecarlin.com | 13015 | tt0484855 | English | George Carlin: Life Is Worth Losing | Carlin returns to the stage in his 13th live c... | ... | 74.0 | English | Released | Some look at life on the bright side. He prefe... | False | 8.1 | 18.0 | Cable Stuff Productions | 2789 | United States of America |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
552 | The Reef 2: High Tide | True | 0 | Animation, Family | http://www.imdb.com/title/tt1978567/ | 132601 | tt1978567 | English | The Reef 2: High Tide | Trained in the skills of sea power, Pi the fis... | ... | 80.0 | English | Released | High Tide: An All New Adventure | False | 2.3 | 6.0 | Wonderworld Studios, Animation Picture Company | 3980, 15196 | United States of America, South Korea |
389 | Birdemic: Shock and Terror | True | 0 | Horror, Science Fiction | http://www.birdemic.com/ | 40016 | tt1316037 | English | Birdemic: Shock and Terror | A platoon of eagles and vultures attacks the r... | ... | 95.0 | English | Released | Why did the eagles and vultures attack? | False | 2.1 | 69.0 | NaN | NaN | United States of America |
660 | Molly: An American Girl on the Home Front | True | 0 | Drama, Family, History | http://www.americangirl.com/movie/molly/about.php | 37453 | tt0828151 | English | Molly: An American Girl on the Home Front | Molly is a girl living in the year 1944 and WW... | ... | 85.0 | NaN | Released | The world is at war and one girl's hope and co... | False | 2.0 | 2.0 | Revolution Studios, Red Om Films, Warner Bros. | 497, 2455, 6194 | Canada, United States of America |
628 | Thou Shalt Laugh 3 | True | 0 | Comedy | http://www.thoushaltlaugh.com/ | 98440 | tt1320113 | English | Thou Shalt Laugh 3 | New from the #1 family comedy series of all-ti... | ... | 94.0 | English | Released | The Next PRETTY-MUCH-PERFECT Installment in th... | False | 0.0 | 0.0 | NaN | NaN | NaN |
629 | Thou Shalt Laugh 2 - The Deuce | True | 0 | Comedy | http://www.thoushaltlaugh.com/ | 98439 | tt1128079 | English | Thou Shalt Laugh 2 - The Deuce | Hot on the heels of the hit DVD Thou Shalt Lau... | ... | 90.0 | English | Released | Seven of the funniest Christian Comedians on e... | False | 0.0 | 0.0 | Phil Cooke Pictures | 9196 | United States of America |
610 rows × 24 columns
9) Select movies or series with long runtime and high rating¶
In [25]:
# Get movies with long runtime and high rating
df_runtime_above_120 = df.loc[(df['runtime'] > 120) & (df['vote_average'] > 7)]
df_runtime_above_120
Out[25]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
34 | Fantasia | True | 2280000 | Animation, Family, Music | http://movies.disney.com/fantasia | 756 | tt0032455 | English | Fantasia | Walt Disney's timeless masterpiece is an extra... | ... | 124.0 | English | Released | The most sensational sound you'll ever see! | False | 7.2 | 831.0 | Walt Disney Pictures | 2 | United States of America |
29 | The Good, the Bad and the Ugly | True | 1200000 | Western | http://www.mgm.com/#/our-titles/766/The-Good,-... | 429 | tt0060196 | Italian | Il buono, il brutto, il cattivo | While the Civil War rages between the Union an... | ... | 161.0 | Italiano | Released | For three men the Civil War wasn't hell. It wa... | False | 8.1 | 2371.0 | United Artists, Constantin Film Produktion, Pr... | 60, 5755, 7508, 42498 | United States of America, Italy, Spain, Germany |
19 | The Godfather | True | 6000000 | Drama, Crime | http://www.thegodfather.com/ | 238 | tt0068646 | English | The Godfather | Spanning the years 1945 to 1955, a chronicle o... | ... | 175.0 | English, Italiano, Latin | Released | An offer you can't refuse. | False | 8.5 | 6024.0 | Paramount Pictures, Alfran Productions | 4, 10211 | United States of America |
44 | The Exorcist | True | 8000000 | Drama, Horror, Thriller | http://theexorcist.warnerbros.com/ | 9552 | tt0070047 | English | The Exorcist | 12-year-old Regan MacNeil begins to adapt an e... | ... | 122.0 | Deutsch, Français, Latin, العربية, ελληνικά, E... | Released | Something almost beyond comprehension is happe... | False | 7.5 | 2046.0 | Warner Bros., Hoya Productions | 6194, 48184 | United States of America |
37 | Jaws | True | 7000000 | Horror, Thriller, Adventure | http://www.jaws25.com/ | 578 | tt0073195 | English | Jaws | An insatiable great white shark terrorizes the... | ... | 124.0 | English | Released | Don't go in the water. | False | 7.5 | 2628.0 | Universal Pictures, Zanuck/Brown Productions | 33, 1865 | United States of America |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
588 | Fantastic Beasts and Where to Find Them | True | 180000000 | Adventure, Family, Fantasy | http://www.fantasticbeasts.com/ | 259316 | tt3183660 | English | Fantastic Beasts and Where to Find Them | In 1926, Newt Scamander arrives at the Magical... | ... | 133.0 | English | Released | From J.K. Rowling's wizarding world. | False | 7.2 | 5612.0 | Heyday films, Warner Bros. | 437, 6194 | United Kingdom, United States of America |
669 | Rogue One: A Star Wars Story | True | 200000000 | Action, Adventure, Science Fiction | http://www.starwars.com/films/rogue-one | 330459 | tt3748528 | English | Rogue One: A Star Wars Story | A rogue band of resistance fighters unite for ... | ... | 133.0 | English | Released | A Rebellion Built on Hope | False | 7.4 | 5111.0 | Lucasfilm, Walt Disney Pictures, Allison Shear... | 1, 2, 47706, 68738, 86561 | United States of America |
675 | Logan | True | 97000000 | Action, Drama, Science Fiction | http://www.foxmovies.com/movies/logan | 263115 | tt3315342 | English | Logan | In the near future, a weary Logan cares for an... | ... | 137.0 | English, Español | Released | His time has come | False | 7.6 | 6310.0 | Twentieth Century Fox Film Corporation, Donner... | 306, 431, 7505, 22213 | United States of America |
561 | Guardians of the Galaxy Vol. 2 | True | 200000000 | Action, Adventure, Comedy, Science Fiction | http://marvel.com/movies/movie/221/guardians_o... | 283995 | tt3896198 | English | Guardians of the Galaxy Vol. 2 | The Guardians must fight to keep their newfoun... | ... | 137.0 | English | Released | Obviously. | False | 7.6 | 4858.0 | Walt Disney Pictures, Marvel Studios | 2, 420 | United States of America |
619 | Wonder Woman | True | 149000000 | Action, Adventure, Fantasy | http://www.warnerbros.com/wonder-woman | 297762 | tt0451279 | English | Wonder Woman | An Amazon princess comes to the world of Man t... | ... | 141.0 | Deutsch, English | Released | Power. Grace. Wisdom. Wonder. | False | 7.2 | 5025.0 | Dune Entertainment, Atlas Entertainment, Warne... | 444, 507, 6194, 9993, 9995, 81620, 83838 | United States of America |
68 rows × 24 columns
10) Sort by genres
(asc) and revenue
(desc)¶
In [28]:
# Sort the df by 'genres' in ascending order and 'revenue' in descending order
df_genres_revenue = df.sort_values(by=['genres', 'revenue'], ascending=[True, False])
df_genres_revenue.head()
Out[28]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
576 | Furious 7 | True | 190000000 | Action | http://www.furious7.com/ | 168259 | tt2820852 | English | Furious 7 | Deckard Shaw seeks revenge against Dominic Tor... | ... | 137.0 | English | Released | Vengeance Hits Home | False | 7.3 | 4253.0 | Universal Pictures, Original Film, Fuji Televi... | 33, 333, 3341, 6452, 7154, 40890, 86352, 86655... | Japan, United States of America |
546 | Maze Runner: The Scorch Trials | True | 61000000 | Action | http://mazerunnermovies.com | 294254 | tt4046784 | English | Maze Runner: The Scorch Trials | Thomas and his fellow Gladers face their great... | ... | 132.0 | English | Released | The Maze Was Just the Beginning. | False | 6.5 | 3148.0 | Gotham Group, Temple Hill Entertainment, TSG E... | 3672, 12292, 22213 | United States of America |
665 | Jack Reacher: Never Go Back | True | 60000000 | Action | http://www.jackreachermovie.com/ | 343611 | tt3393786 | English | Jack Reacher: Never Go Back | Jack Reacher must uncover the truth behind a m... | ... | 118.0 | English | Released | Justice is Coming. | False | 5.3 | 1843.0 | Paramount Pictures, Shanghai Film Group, TC Pr... | 4, 3407, 21777, 82819, 83645 | China, United States of America |
188 | Azumi 2: Death or Love | True | 0 | Action | http://web.archive.org/web/20080210100832/http... | 5890 | tt0431641 | Japanese | あずみ2 Death or Love | Young assassins Azumi and Nagara continue thei... | ... | 108.0 | 日本語, Português | Released | Love Or Duty... An Assassin Must Choose | False | 6.4 | 45.0 | NaN | NaN | Japan |
408 | Born To Race | True | 0 | Action | http://www.borntoracemovie.com/Site/Home.html | 74523 | tt1781781 | English | Born To Race | Born To Race is the story of Danny Krueger, a ... | ... | 99.0 | English | Released | Only one can win it all. | False | 5.5 | 41.0 | American Cinema International, ESX Productions | 10700, 37081 | United States of America |
5 rows × 24 columns
11) Select movies or series that have the Action
genre and sort them by voting average and revenue¶
In [36]:
# Filter the DataFrame to include only movies with 'Action' genre
df_action = df.loc[df['genres'].str.contains('Action')].sort_values(by=['vote_average', 'revenue'], ascending=[False, True])
df_action.head()
Out[36]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
237 | The Dark Knight | True | 185000000 | Drama, Action, Crime, Thriller | http://thedarkknight.warnerbros.com/dvdsite/ | 155 | tt0468569 | English | The Dark Knight | Batman raises the stakes in his war on crime. ... | ... | 152.0 | English, 普通话 | Released | Why So Serious? | False | 8.3 | 12269.0 | DC Comics, Legendary Pictures, Warner Bros., D... | 429, 923, 6194, 9993, 9996 | United Kingdom, United States of America |
27 | The Empire Strikes Back | True | 18000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 1891 | tt0080684 | English | The Empire Strikes Back | The epic saga continues as Luke Skywalker, in ... | ... | 124.0 | English | Released | The Adventure Continues... | False | 8.2 | 5998.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
6 | Star Wars | True | 11000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 11 | tt0076759 | English | Star Wars | Princess Leia is captured and held hostage by ... | ... | 121.0 | English | Released | A long time ago in a galaxy far, far away... | False | 8.1 | 6778.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
132 | The Lord of the Rings: The Return of the King | True | 94000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net | 122 | tt0167260 | English | The Lord of the Rings: The Return of the King | Aragorn is revealed as the heir to the ancient... | ... | 201.0 | English | Released | The eye of the enemy is moving. | False | 8.1 | 8226.0 | WingNut Films, New Line Cinema | 11, 12 | New Zealand, United States of America |
103 | The Lord of the Rings: The Fellowship of the Ring | True | 93000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net/ | 120 | tt0120737 | English | The Lord of the Rings: The Fellowship of the Ring | Young hobbit Frodo Baggins, after inheriting a... | ... | 178.0 | English | Released | One ring to rule them all | False | 8.0 | 8892.0 | WingNut Films, New Line Cinema, The Saul Zaent... | 11, 12, 5237 | New Zealand, United States of America |
5 rows × 24 columns
12) Select movies or series with a budget > 50,000,000
and runtime > 120 minutes
¶
Let's visualize the budget
column. We can see the green line, which represents the median
(50th percentile)
of the data. The individual circles above the top whisker represent outliers, which are data points that lie more than 1.5
times the interquartile range (IQR)
from the 75th
percentile.
In [38]:
df['budget'].plot(kind='box')
Out[38]:
<Axes: >
In [39]:
# Create a new DataFrame 'df_bug_run' with filtered rows and selected columns
df_budget_runtime = df.loc[(df['budget'] > 50_000_000) & (df['runtime'] > 120), ['original_title', 'budget', 'runtime']]
df_budget_runtime.head()
Out[39]:
original_title | budget | runtime | |
---|---|---|---|
48 | The Godfather: Part III | 54000000 | 162.0 |
9 | Jurassic Park | 63000000 | 127.0 |
0 | GoldenEye | 58000000 | 130.0 |
58 | The Matrix | 63000000 | 136.0 |
59 | The Mummy | 80000000 | 124.0 |
13) Select movies or series that have the Action
and Adventure
genres and voting average is high and sort them by vote_average
(asc) and revenue
(asc)¶
In [50]:
# Filter the df with 'Action' or 'Adventure' genre and a vote_average greater than 7 then sort the df by 'vote_average' in descending order and 'revenue' in ascending order
df_act_adv = df.loc[(df['genres'].str.contains('Action|Adventure', regex=True)) & (df['vote_average'] > 7)].sort_values(by=['vote_average', 'revenue'], ascending=[False, True])
df_act_adv.head(3)
Out[50]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
237 | The Dark Knight | True | 185000000 | Drama, Action, Crime, Thriller | http://thedarkknight.warnerbros.com/dvdsite/ | 155 | tt0468569 | English | The Dark Knight | Batman raises the stakes in his war on crime. ... | ... | 152.0 | English, 普通话 | Released | Why So Serious? | False | 8.3 | 12269.0 | DC Comics, Legendary Pictures, Warner Bros., D... | 429, 923, 6194, 9993, 9996 | United Kingdom, United States of America |
27 | The Empire Strikes Back | True | 18000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 1891 | tt0080684 | English | The Empire Strikes Back | The epic saga continues as Luke Skywalker, in ... | ... | 124.0 | English | Released | The Adventure Continues... | False | 8.2 | 5998.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
6 | Star Wars | True | 11000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 11 | tt0076759 | English | Star Wars | Princess Leia is captured and held hostage by ... | ... | 121.0 | English | Released | A long time ago in a galaxy far, far away... | False | 8.1 | 6778.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
3 rows × 24 columns
14) Select movies or series that have Star Wars
in the title
and sort them by release_date
(asc) and revenue
(desc).¶
In [52]:
# Filter the df with 'Star Wars' in the original title and sort them by release_date' in ascending order and 'revenue' in descending order
df_star_wars = df.loc[df['original_title'].str.contains('Star Wars')].sort_values(by=['release_date', 'revenue'], ascending=[True, False])
df_star_wars.head()
Out[52]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6 | Star Wars | True | 11000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 11 | tt0076759 | English | Star Wars | Princess Leia is captured and held hostage by ... | ... | 121.0 | English | Released | A long time ago in a galaxy far, far away... | False | 8.1 | 6778.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
60 | Star Wars: Episode I - The Phantom Menace | True | 115000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 1893 | tt0120915 | English | Star Wars: Episode I - The Phantom Menace | Anakin Skywalker, a young slave strong with th... | ... | 136.0 | English | Released | Every generation has a legend. Every journey h... | False | 6.4 | 4526.0 | Lucasfilm | 1 | United States of America |
110 | Star Wars: Episode II - Attack of the Clones | True | 120000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 1894 | tt0121765 | English | Star Wars: Episode II - Attack of the Clones | Ten years after the invasion of Naboo, the gal... | ... | 142.0 | English | Released | A Jedi Shall Not Know Anger. Nor Hatred. Nor L... | False | 6.4 | 4074.0 | Lucasfilm | 1 | United States of America |
159 | Star Wars: Episode III - Revenge of the Sith | True | 113000000 | Science Fiction, Adventure, Action | http://www.starwars.com/films/star-wars-episod... | 1895 | tt0121766 | English | Star Wars: Episode III - Revenge of the Sith | Years after the onset of the Clone Wars, the n... | ... | 140.0 | English | Released | The saga is complete. | False | 7.1 | 4200.0 | Lucasfilm | 1 | United States of America |
557 | Star Wars: The Force Awakens | True | 245000000 | Action, Adventure, Science Fiction, Fantasy | http://www.starwars.com/films/star-wars-episod... | 140607 | tt2488496 | English | Star Wars: The Force Awakens | Thirty years after defeating the Galactic Empi... | ... | 136.0 | English | Released | Every generation has a story. | False | 7.5 | 7993.0 | Lucasfilm, Truenorth Productions, Bad Robot | 1, 1634, 11461 | United States of America |
5 rows × 24 columns
15) Select original_title
, budget
, revenue
, and vote_average
of the rows with a budget greater than 100M.¶
In [54]:
# Filter DataFrame for high-budget movies and select relevant columns
df_high_budget = df.loc[df['budget'] > 100_000_000, ['original_title', 'budget', 'revenue', 'vote_average']]
df_high_budget.head()
Out[54]:
original_title | budget | revenue | vote_average | |
---|---|---|---|---|
41 | Tomorrow Never Dies | 110000000 | 333011068.0 | 6.0 |
60 | Star Wars: Episode I - The Phantom Menace | 115000000 | 924317558.0 | 6.4 |
62 | Tarzan | 150000000 | 448000000.0 | 7.1 |
74 | The World Is Not Enough | 135000000 | 361832400.0 | 6.0 |
81 | Mission: Impossible II | 125000000 | 546388105.0 | 5.9 |
16) Find the movies with a runtime greater than 120 and a vote average greater than 7. Sort them in descending order.¶
Run the cell below to see the histogram, which shows a right-skewed distribution of movie runtimes. The highest frequency is around 130 minutes. This indicates a predominance of movies around 2 hours long. Very short or very long movies are relatively rare.
In [56]:
df['runtime'].plot(kind='hist', bins=20, figsize=(10, 6), title='Distribution of Movie Runtimes');
In [57]:
df_run_vote = df.loc[(df['runtime'] > 120) & (df['vote_average'] > 7)].sort_values(by='runtime', ascending=False)
df_run_vote.head()
Out[57]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
132 | The Lord of the Rings: The Return of the King | True | 94000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net | 122 | tt0167260 | English | The Lord of the Rings: The Return of the King | Aragorn is revealed as the heir to the ancient... | ... | 201.0 | English | Released | The eye of the enemy is moving. | False | 8.1 | 8226.0 | WingNut Films, New Line Cinema | 11, 12 | New Zealand, United States of America |
119 | The Lord of the Rings: The Two Towers | True | 79000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net/ | 121 | tt0167261 | English | The Lord of the Rings: The Two Towers | Frodo and Sam are trekking to Mordor to destro... | ... | 179.0 | English | Released | A New Power Is Rising. | False | 8.0 | 7641.0 | WingNut Films, New Line Cinema, The Saul Zaent... | 11, 12, 5237 | New Zealand, United States of America |
103 | The Lord of the Rings: The Fellowship of the Ring | True | 93000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net/ | 120 | tt0120737 | English | The Lord of the Rings: The Fellowship of the Ring | Young hobbit Frodo Baggins, after inheriting a... | ... | 178.0 | English | Released | One ring to rule them all | False | 8.0 | 8892.0 | WingNut Films, New Line Cinema, The Saul Zaent... | 11, 12, 5237 | New Zealand, United States of America |
465 | Don : The Chase Begins Again | True | 7100000 | Action, Drama, Thriller | http://www.donthefilm.com/ | 17501 | tt0461936 | Hindi | Don : The Chase Begins Again | A huge South Asian law enforcement contingent ... | ... | 178.0 | हिन्दी | Released | The Chase Begins Again | False | 7.3 | 68.0 | Excel Entertainment, Eros International | 2934, 3653 | India |
19 | The Godfather | True | 6000000 | Drama, Crime | http://www.thegodfather.com/ | 238 | tt0068646 | English | The Godfather | Spanning the years 1945 to 1955, a chronicle o... | ... | 175.0 | English, Italiano, Latin | Released | An offer you can't refuse. | False | 8.5 | 6024.0 | Paramount Pictures, Alfran Productions | 4, 10211 | United States of America |
5 rows × 24 columns
17) Find the top 10 movies or series with highest voting count and a voting average greater than 7 and select original_title
, vote_count
, and vote_average
columns.¶
In [61]:
df_top_10 = df.loc[(df['vote_count'] > 1000) & (df['vote_average'] > 7), ['original_title', 'vote_count', 'vote_average']][:10]
df_top_10
Out[61]:
original_title | vote_count | vote_average | |
---|---|---|---|
66 | Goldfinger | 1005.0 | 7.2 |
29 | Il buono, il brutto, il cattivo | 2371.0 | 8.1 |
49 | The Jungle Book | 1791.0 | 7.1 |
19 | The Godfather | 6024.0 | 8.5 |
44 | The Exorcist | 2046.0 | 7.5 |
37 | Jaws | 2628.0 | 7.5 |
6 | Star Wars | 6778.0 | 8.1 |
42 | Halloween | 1066.0 | 7.4 |
31 | Alien | 4564.0 | 7.9 |
27 | The Empire Strikes Back | 5998.0 | 8.2 |
In [64]:
df.query('vote_count > 1000 & vote_average > 7')
Out[64]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
66 | Goldfinger | True | 2500000 | Adventure, Action, Thriller | http://www.mgm.com/view/movie/760/Goldfinger/ | 658 | tt0058150 | English | Goldfinger | Special agent 007 (Sean Connery) comes face to... | ... | 110.0 | 普通话, English, Español | Released | Everything he touches turns into excitement! | False | 7.2 | 1005.0 | United Artists, Eon Productions, Danjaq | 60, 7576, 10761 | United Kingdom, United States of America |
29 | The Good, the Bad and the Ugly | True | 1200000 | Western | http://www.mgm.com/#/our-titles/766/The-Good,-... | 429 | tt0060196 | Italian | Il buono, il brutto, il cattivo | While the Civil War rages between the Union an... | ... | 161.0 | Italiano | Released | For three men the Civil War wasn't hell. It wa... | False | 8.1 | 2371.0 | United Artists, Constantin Film Produktion, Pr... | 60, 5755, 7508, 42498 | United States of America, Italy, Spain, Germany |
49 | The Jungle Book | True | 4000000 | Family, Animation, Adventure | http://movies.disney.com/the-jungle-book-1967 | 9325 | tt0061852 | English | The Jungle Book | The boy Mowgli makes his way to the man-villag... | ... | 78.0 | English | Released | The Jungle is JUMPIN'! | False | 7.1 | 1791.0 | Walt Disney Pictures | 2 | United States of America |
19 | The Godfather | True | 6000000 | Drama, Crime | http://www.thegodfather.com/ | 238 | tt0068646 | English | The Godfather | Spanning the years 1945 to 1955, a chronicle o... | ... | 175.0 | English, Italiano, Latin | Released | An offer you can't refuse. | False | 8.5 | 6024.0 | Paramount Pictures, Alfran Productions | 4, 10211 | United States of America |
44 | The Exorcist | True | 8000000 | Drama, Horror, Thriller | http://theexorcist.warnerbros.com/ | 9552 | tt0070047 | English | The Exorcist | 12-year-old Regan MacNeil begins to adapt an e... | ... | 122.0 | Deutsch, Français, Latin, العربية, ελληνικά, E... | Released | Something almost beyond comprehension is happe... | False | 7.5 | 2046.0 | Warner Bros., Hoya Productions | 6194, 48184 | United States of America |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
669 | Rogue One: A Star Wars Story | True | 200000000 | Action, Adventure, Science Fiction | http://www.starwars.com/films/rogue-one | 330459 | tt3748528 | English | Rogue One: A Star Wars Story | A rogue band of resistance fighters unite for ... | ... | 133.0 | English | Released | A Rebellion Built on Hope | False | 7.4 | 5111.0 | Lucasfilm, Walt Disney Pictures, Allison Shear... | 1, 2, 47706, 68738, 86561 | United States of America |
672 | The Lego Batman Movie | True | 80000000 | Action, Animation, Comedy, Family, Fantasy | http://www.legobatman.com | 324849 | tt4116284 | English | The Lego Batman Movie | In the irreverent spirit of fun that made “The... | ... | 104.0 | English | Released | Always be yourself. Unless you can be Batman. | False | 7.2 | 1473.0 | Lin Pictures, Warner Bros. Animation, Warner B... | 2723, 2785, 6194, 8089, 9993, 77973, 85983 | Denmark, United States of America |
675 | Logan | True | 97000000 | Action, Drama, Science Fiction | http://www.foxmovies.com/movies/logan | 263115 | tt3315342 | English | Logan | In the near future, a weary Logan cares for an... | ... | 137.0 | English, Español | Released | His time has come | False | 7.6 | 6310.0 | Twentieth Century Fox Film Corporation, Donner... | 306, 431, 7505, 22213 | United States of America |
561 | Guardians of the Galaxy Vol. 2 | True | 200000000 | Action, Adventure, Comedy, Science Fiction | http://marvel.com/movies/movie/221/guardians_o... | 283995 | tt3896198 | English | Guardians of the Galaxy Vol. 2 | The Guardians must fight to keep their newfoun... | ... | 137.0 | English | Released | Obviously. | False | 7.6 | 4858.0 | Walt Disney Pictures, Marvel Studios | 2, 420 | United States of America |
619 | Wonder Woman | True | 149000000 | Action, Adventure, Fantasy | http://www.warnerbros.com/wonder-woman | 297762 | tt0451279 | English | Wonder Woman | An Amazon princess comes to the world of Man t... | ... | 141.0 | Deutsch, English | Released | Power. Grace. Wisdom. Wonder. | False | 7.2 | 5025.0 | Dune Entertainment, Atlas Entertainment, Warne... | 444, 507, 6194, 9993, 9995, 81620, 83838 | United States of America |
99 rows × 24 columns
18) Find the movies or series that have a vote_average
above 8 or have made more than 500,000,000 in revenue
.¶
In [66]:
# Filter the DataFrame to include movies with vote_average > 8 or revenue > $500,000,000
df_high = df.loc[(df['revenue'] > 500_000_000) | (df['vote_average'] > 8)]
df_high.head()
Out[66]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
29 | The Good, the Bad and the Ugly | True | 1200000 | Western | http://www.mgm.com/#/our-titles/766/The-Good,-... | 429 | tt0060196 | Italian | Il buono, il brutto, il cattivo | While the Civil War rages between the Union an... | ... | 161.0 | Italiano | Released | For three men the Civil War wasn't hell. It wa... | False | 8.1 | 2371.0 | United Artists, Constantin Film Produktion, Pr... | 60, 5755, 7508, 42498 | United States of America, Italy, Spain, Germany |
19 | The Godfather | True | 6000000 | Drama, Crime | http://www.thegodfather.com/ | 238 | tt0068646 | English | The Godfather | Spanning the years 1945 to 1955, a chronicle o... | ... | 175.0 | English, Italiano, Latin | Released | An offer you can't refuse. | False | 8.5 | 6024.0 | Paramount Pictures, Alfran Productions | 4, 10211 | United States of America |
6 | Star Wars | True | 11000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 11 | tt0076759 | English | Star Wars | Princess Leia is captured and held hostage by ... | ... | 121.0 | English | Released | A long time ago in a galaxy far, far away... | False | 8.1 | 6778.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
27 | The Empire Strikes Back | True | 18000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 1891 | tt0080684 | English | The Empire Strikes Back | The epic saga continues as Luke Skywalker, in ... | ... | 124.0 | English | Released | The Adventure Continues... | False | 8.2 | 5998.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
30 | Return of the Jedi | True | 32350000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 1892 | tt0086190 | English | Return of the Jedi | As Rebel leaders map their strategy for an all... | ... | 135.0 | English | Released | The Empire Falls... | False | 7.9 | 4763.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
5 rows × 24 columns
19) Enter the release date of the movie that is not in English
.¶
Run the cell below to see the bar plot, there are many movies and series in the English language, but few are non-English, including Hindi, Japanese, Chinese, etc.
In [68]:
df['original_language'].value_counts().plot(kind='bar', title='Count of Movies by Language', figsize=(10, 5));
In [73]:
sorted_non_english_movies = df.loc[df['original_language'] != 'English', ['title', 'original_language', 'release_date']].sort_values(by='release_date')
sorted_non_english_movies.head()
Out[73]:
title | original_language | release_date | |
---|---|---|---|
95 | La Notte | Italian | 1961-01-23 |
29 | The Good, the Bad and the Ugly | Italian | 1966-12-23 |
16 | Touki Bouki | Wolof | 1973-07-01 |
515 | Trances | Arabic | 1981-10-03 |
150 | Pusher | Danish | 1996-08-30 |
20) Select movies with runtime > 150
, vote_average > 7
, popularity > 20
, and sort them by descending order.¶
In [78]:
df_long_movies = df.loc[(df['runtime'] > 150) & (df['vote_average'] > 7) & (df['popularity'] > 20) ].sort_values(by='vote_average', ascending=False)
df_long_movies.head()
Out[78]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
19 | The Godfather | True | 6000000 | Drama, Crime | http://www.thegodfather.com/ | 238 | tt0068646 | English | The Godfather | Spanning the years 1945 to 1955, a chronicle o... | ... | 175.0 | English, Italiano, Latin | Released | An offer you can't refuse. | False | 8.5 | 6024.0 | Paramount Pictures, Alfran Productions | 4, 10211 | United States of America |
237 | The Dark Knight | True | 185000000 | Drama, Action, Crime, Thriller | http://thedarkknight.warnerbros.com/dvdsite/ | 155 | tt0468569 | English | The Dark Knight | Batman raises the stakes in his war on crime. ... | ... | 152.0 | English, 普通话 | Released | Why So Serious? | False | 8.3 | 12269.0 | DC Comics, Legendary Pictures, Warner Bros., D... | 429, 923, 6194, 9993, 9996 | United Kingdom, United States of America |
132 | The Lord of the Rings: The Return of the King | True | 94000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net | 122 | tt0167260 | English | The Lord of the Rings: The Return of the King | Aragorn is revealed as the heir to the ancient... | ... | 201.0 | English | Released | The eye of the enemy is moving. | False | 8.1 | 8226.0 | WingNut Films, New Line Cinema | 11, 12 | New Zealand, United States of America |
103 | The Lord of the Rings: The Fellowship of the Ring | True | 93000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net/ | 120 | tt0120737 | English | The Lord of the Rings: The Fellowship of the Ring | Young hobbit Frodo Baggins, after inheriting a... | ... | 178.0 | English | Released | One ring to rule them all | False | 8.0 | 8892.0 | WingNut Films, New Line Cinema, The Saul Zaent... | 11, 12, 5237 | New Zealand, United States of America |
119 | The Lord of the Rings: The Two Towers | True | 79000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net/ | 121 | tt0167261 | English | The Lord of the Rings: The Two Towers | Frodo and Sam are trekking to Mordor to destro... | ... | 179.0 | English | Released | A New Power Is Rising. | False | 8.0 | 7641.0 | WingNut Films, New Line Cinema, The Saul Zaent... | 11, 12, 5237 | New Zealand, United States of America |
5 rows × 24 columns
21) Find movies in the Action, Adventure, or Science Fiction genres and sort them by descending order¶
In [81]:
df_action_sci_adv = df.loc[df['genres'].str.contains('Action|Adventure|Science Fiction')].sort_values(by='runtime', ascending=False)
df_action_sci_adv.head()
Out[81]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
132 | The Lord of the Rings: The Return of the King | True | 94000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net | 122 | tt0167260 | English | The Lord of the Rings: The Return of the King | Aragorn is revealed as the heir to the ancient... | ... | 201.0 | English | Released | The eye of the enemy is moving. | False | 8.1 | 8226.0 | WingNut Films, New Line Cinema | 11, 12 | New Zealand, United States of America |
119 | The Lord of the Rings: The Two Towers | True | 79000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net/ | 121 | tt0167261 | English | The Lord of the Rings: The Two Towers | Frodo and Sam are trekking to Mordor to destro... | ... | 179.0 | English | Released | A New Power Is Rising. | False | 8.0 | 7641.0 | WingNut Films, New Line Cinema, The Saul Zaent... | 11, 12, 5237 | New Zealand, United States of America |
103 | The Lord of the Rings: The Fellowship of the Ring | True | 93000000 | Adventure, Fantasy, Action | http://www.lordoftherings.net/ | 120 | tt0120737 | English | The Lord of the Rings: The Fellowship of the Ring | Young hobbit Frodo Baggins, after inheriting a... | ... | 178.0 | English | Released | One ring to rule them all | False | 8.0 | 8892.0 | WingNut Films, New Line Cinema, The Saul Zaent... | 11, 12, 5237 | New Zealand, United States of America |
465 | Don : The Chase Begins Again | True | 7100000 | Action, Drama, Thriller | http://www.donthefilm.com/ | 17501 | tt0461936 | Hindi | Don : The Chase Begins Again | A huge South Asian law enforcement contingent ... | ... | 178.0 | हिन्दी | Released | The Chase Begins Again | False | 7.3 | 68.0 | Excel Entertainment, Eros International | 2934, 3653 | India |
208 | Pirates of the Caribbean: At World's End | True | 300000000 | Adventure, Fantasy, Action | http://disney.go.com/disneypictures/pirates/ | 285 | tt0449088 | English | Pirates of the Caribbean: At World's End | Captain Barbossa, long believed to be dead, ha... | ... | 169.0 | English | Released | At the end of the world, the adventure begins. | False | 6.9 | 4627.0 | Walt Disney Pictures, Jerry Bruckheimer Films,... | 2, 130, 19936 | United States of America |
5 rows × 24 columns
22) Find movies with a budget under 20M and revenue over 100M and sort them by descending order.¶
In [85]:
df_budget_revenue = df.loc[(df['budget'] < 20_000_000) & (df['revenue'] > 100_000_000)].sort_values(by='revenue', ascending=False)
df_budget_revenue.head()
Out[85]:
title | adult | budget | genres | homepage | id | imdb_id | original_language | original_title | overview | ... | runtime | spoken_languages | status | tagline | video | vote_average | vote_count | production_companies_name | production_companies_id | production_countries_name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6 | Star Wars | True | 11000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 11 | tt0076759 | English | Star Wars | Princess Leia is captured and held hostage by ... | ... | 121.0 | English | Released | A long time ago in a galaxy far, far away... | False | 8.1 | 6778.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
27 | The Empire Strikes Back | True | 18000000 | Adventure, Action, Science Fiction | http://www.starwars.com/films/star-wars-episod... | 1891 | tt0080684 | English | The Empire Strikes Back | The epic saga continues as Luke Skywalker, in ... | ... | 124.0 | English | Released | The Adventure Continues... | False | 8.2 | 5998.0 | Lucasfilm, Twentieth Century Fox Film Corporation | 1, 306 | United States of America |
11 | Home Alone | True | 18000000 | Comedy, Family | https://www.foxconnect.com/home-alone-4.html | 771 | tt0099785 | English | Home Alone | Eight-year-old Kevin McCallister makes the mos... | ... | 103.0 | English | Released | A Family Comedy Without the Family. | False | 7.1 | 2487.0 | Twentieth Century Fox Film Corporation, Hughes... | 306, 477 | United States of America |
37 | Jaws | True | 7000000 | Horror, Thriller, Adventure | http://www.jaws25.com/ | 578 | tt0073195 | English | Jaws | An insatiable great white shark terrorizes the... | ... | 124.0 | English | Released | Don't go in the water. | False | 7.5 | 2628.0 | Universal Pictures, Zanuck/Brown Productions | 33, 1865 | United States of America |
44 | The Exorcist | True | 8000000 | Drama, Horror, Thriller | http://theexorcist.warnerbros.com/ | 9552 | tt0070047 | English | The Exorcist | 12-year-old Regan MacNeil begins to adapt an e... | ... | 122.0 | Deutsch, Français, Latin, العربية, ελληνικά, E... | Released | Something almost beyond comprehension is happe... | False | 7.5 | 2046.0 | Warner Bros., Hoya Productions | 6194, 48184 | United States of America |
5 rows × 24 columns
In [ ]: