diff --git a/README.md b/README.md index 29e3981..102cd35 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,14 @@ df.apply(lambda x: func( x['col1'], x['col2']), axis=1 ) > This will allow you to create pretty much any logic, I promise!!! ### :file_folder: **Data** -To perform the challenges you will use the dataset `/data/imput/IMDB-Movie-Data.csv` +To perform the challenges you will use the dataset `/data/input/IMDB-Movie-Data.csv` ### :panda_face: **Challenge 1. Warm up** We want to create **bins** of movies according to the number of votes they've received. For that matter, we will create a new column named **'bin'** which will tag every movie as follow: -- From 0 to 1000 ==> 1 -- From 1000 to 10000 ==> 2 -- From 10000 to 100000 ==> 3 -- From 100000 to 1000000 ==> 4 +- From 0 to 999 ==> 1 +- From 1000 to 9999 ==> 2 +- From 10000 to 99999 ==> 3 +- From 100000 to 999999 ==> 4 - More than 1000000 ==> 5 ### :panda_face: :panda_face: **Challenge 2. Using axis concept** diff --git a/notebooks/pandas_apply_lambda.ipynb b/notebooks/pandas_apply_lambda.ipynb new file mode 100644 index 0000000..ef2ec66 --- /dev/null +++ b/notebooks/pandas_apply_lambda.ipynb @@ -0,0 +1,3199 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "fc423f71", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "2a36bfdd", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 1000 entries, 0 to 999\n", + "Data columns (total 12 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 Rank 1000 non-null int64 \n", + " 1 Title 1000 non-null object \n", + " 2 Genre 1000 non-null object \n", + " 3 Description 1000 non-null object \n", + " 4 Director 1000 non-null object \n", + " 5 Actors 1000 non-null object \n", + " 6 Year 1000 non-null int64 \n", + " 7 Runtime (Minutes) 1000 non-null int64 \n", + " 8 Rating 1000 non-null float64\n", + " 9 Votes 1000 non-null int64 \n", + " 10 Revenue (Millions) 872 non-null float64\n", + " 11 Metascore 936 non-null float64\n", + "dtypes: float64(3), int64(4), object(5)\n", + "memory usage: 93.9+ KB\n" + ] + } + ], + "source": [ + "df = pd.read_csv('../data/input/IMDB-Movie-Data.csv')\n", + "df.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "d94bcaca", + "metadata": {}, + "outputs": [], + "source": [ + "def movie_votes(votes):\n", + " if 0 < votes <= 999:\n", + " return 1\n", + " elif 999 < votes <= 9999:\n", + " return 2\n", + " elif 9999 < votes <= 99999:\n", + " return 3\n", + " elif 99999 < votes <= 999999:\n", + " return 4\n", + " elif 999999 < votes:\n", + " return 5" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "f90801ed", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)Metascorebins
01Guardians of the GalaxyAction,Adventure,Sci-FiA group of intergalactic criminals are forced ...James GunnChris Pratt, Vin Diesel, Bradley Cooper, Zoe S...20141218.1757074333.1376.04
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.04
23SplitHorror,ThrillerThree girls are kidnapped by a man with a diag...M. Night ShyamalanJames McAvoy, Anya Taylor-Joy, Haley Lu Richar...20161177.3157606138.1262.04
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.03
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.04
..........................................
995996Secret in Their EyesCrime,Drama,MysteryA tight-knit team of rising investigators, alo...Billy RayChiwetel Ejiofor, Nicole Kidman, Julia Roberts...20151116.227585NaN45.03
996997Hostel: Part IIHorrorThree American college students studying abroa...Eli RothLauren German, Heather Matarazzo, Bijou Philli...2007945.57315217.5446.03
997998Step Up 2: The StreetsDrama,Music,RomanceRomantic sparks occur between two dance studen...Jon M. ChuRobert Hoffman, Briana Evigan, Cassie Ventura,...2008986.27069958.0150.03
998999Search PartyAdventure,ComedyA pair of friends embark on a mission to reuni...Scot ArmstrongAdam Pally, T.J. Miller, Thomas Middleditch,Sh...2014935.64881NaN22.02
9991000Nine LivesComedy,Family,FantasyA stuffy businessman finds himself trapped ins...Barry SonnenfeldKevin Spacey, Jennifer Garner, Robbie Amell,Ch...2016875.31243519.6411.03
\n", + "

1000 rows × 13 columns

\n", + "
" + ], + "text/plain": [ + " Rank Title Genre \\\n", + "0 1 Guardians of the Galaxy Action,Adventure,Sci-Fi \n", + "1 2 Prometheus Adventure,Mystery,Sci-Fi \n", + "2 3 Split Horror,Thriller \n", + "3 4 Sing Animation,Comedy,Family \n", + "4 5 Suicide Squad Action,Adventure,Fantasy \n", + ".. ... ... ... \n", + "995 996 Secret in Their Eyes Crime,Drama,Mystery \n", + "996 997 Hostel: Part II Horror \n", + "997 998 Step Up 2: The Streets Drama,Music,Romance \n", + "998 999 Search Party Adventure,Comedy \n", + "999 1000 Nine Lives Comedy,Family,Fantasy \n", + "\n", + " Description Director \\\n", + "0 A group of intergalactic criminals are forced ... James Gunn \n", + "1 Following clues to the origin of mankind, a te... Ridley Scott \n", + "2 Three girls are kidnapped by a man with a diag... M. Night Shyamalan \n", + "3 In a city of humanoid animals, a hustling thea... Christophe Lourdelet \n", + "4 A secret government agency recruits some of th... David Ayer \n", + ".. ... ... \n", + "995 A tight-knit team of rising investigators, alo... Billy Ray \n", + "996 Three American college students studying abroa... Eli Roth \n", + "997 Romantic sparks occur between two dance studen... Jon M. Chu \n", + "998 A pair of friends embark on a mission to reuni... Scot Armstrong \n", + "999 A stuffy businessman finds himself trapped ins... Barry Sonnenfeld \n", + "\n", + " Actors Year \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 \n", + ".. ... ... \n", + "995 Chiwetel Ejiofor, Nicole Kidman, Julia Roberts... 2015 \n", + "996 Lauren German, Heather Matarazzo, Bijou Philli... 2007 \n", + "997 Robert Hoffman, Briana Evigan, Cassie Ventura,... 2008 \n", + "998 Adam Pally, T.J. Miller, Thomas Middleditch,Sh... 2014 \n", + "999 Kevin Spacey, Jennifer Garner, Robbie Amell,Ch... 2016 \n", + "\n", + " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore bins \n", + "0 121 8.1 757074 333.13 76.0 4 \n", + "1 124 7.0 485820 126.46 65.0 4 \n", + "2 117 7.3 157606 138.12 62.0 4 \n", + "3 108 7.2 60545 270.32 59.0 3 \n", + "4 123 6.2 393727 325.02 40.0 4 \n", + ".. ... ... ... ... ... ... \n", + "995 111 6.2 27585 NaN 45.0 3 \n", + "996 94 5.5 73152 17.54 46.0 3 \n", + "997 98 6.2 70699 58.01 50.0 3 \n", + "998 93 5.6 4881 NaN 22.0 2 \n", + "999 87 5.3 12435 19.64 11.0 3 \n", + "\n", + "[1000 rows x 13 columns]" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['bins'] = df.apply(lambda x : movie_votes( x['Votes']), axis=1)\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "2ebf1ff6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)MetascorebinsRev_Mins
01Guardians of the GalaxyAction,Adventure,Sci-FiA group of intergalactic criminals are forced ...James GunnChris Pratt, Vin Diesel, Bradley Cooper, Zoe S...20141218.1757074333.1376.042.753140
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.041.019839
23SplitHorror,ThrillerThree girls are kidnapped by a man with a diag...M. Night ShyamalanJames McAvoy, Anya Taylor-Joy, Haley Lu Richar...20161177.3157606138.1262.041.180513
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.032.502963
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.042.642439
.............................................
995996Secret in Their EyesCrime,Drama,MysteryA tight-knit team of rising investigators, alo...Billy RayChiwetel Ejiofor, Nicole Kidman, Julia Roberts...20151116.227585NaN45.03NaN
996997Hostel: Part IIHorrorThree American college students studying abroa...Eli RothLauren German, Heather Matarazzo, Bijou Philli...2007945.57315217.5446.030.186596
997998Step Up 2: The StreetsDrama,Music,RomanceRomantic sparks occur between two dance studen...Jon M. ChuRobert Hoffman, Briana Evigan, Cassie Ventura,...2008986.27069958.0150.030.591939
998999Search PartyAdventure,ComedyA pair of friends embark on a mission to reuni...Scot ArmstrongAdam Pally, T.J. Miller, Thomas Middleditch,Sh...2014935.64881NaN22.02NaN
9991000Nine LivesComedy,Family,FantasyA stuffy businessman finds himself trapped ins...Barry SonnenfeldKevin Spacey, Jennifer Garner, Robbie Amell,Ch...2016875.31243519.6411.030.225747
\n", + "

1000 rows × 14 columns

\n", + "
" + ], + "text/plain": [ + " Rank Title Genre \\\n", + "0 1 Guardians of the Galaxy Action,Adventure,Sci-Fi \n", + "1 2 Prometheus Adventure,Mystery,Sci-Fi \n", + "2 3 Split Horror,Thriller \n", + "3 4 Sing Animation,Comedy,Family \n", + "4 5 Suicide Squad Action,Adventure,Fantasy \n", + ".. ... ... ... \n", + "995 996 Secret in Their Eyes Crime,Drama,Mystery \n", + "996 997 Hostel: Part II Horror \n", + "997 998 Step Up 2: The Streets Drama,Music,Romance \n", + "998 999 Search Party Adventure,Comedy \n", + "999 1000 Nine Lives Comedy,Family,Fantasy \n", + "\n", + " Description Director \\\n", + "0 A group of intergalactic criminals are forced ... James Gunn \n", + "1 Following clues to the origin of mankind, a te... Ridley Scott \n", + "2 Three girls are kidnapped by a man with a diag... M. Night Shyamalan \n", + "3 In a city of humanoid animals, a hustling thea... Christophe Lourdelet \n", + "4 A secret government agency recruits some of th... David Ayer \n", + ".. ... ... \n", + "995 A tight-knit team of rising investigators, alo... Billy Ray \n", + "996 Three American college students studying abroa... Eli Roth \n", + "997 Romantic sparks occur between two dance studen... Jon M. Chu \n", + "998 A pair of friends embark on a mission to reuni... Scot Armstrong \n", + "999 A stuffy businessman finds himself trapped ins... Barry Sonnenfeld \n", + "\n", + " Actors Year \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 \n", + ".. ... ... \n", + "995 Chiwetel Ejiofor, Nicole Kidman, Julia Roberts... 2015 \n", + "996 Lauren German, Heather Matarazzo, Bijou Philli... 2007 \n", + "997 Robert Hoffman, Briana Evigan, Cassie Ventura,... 2008 \n", + "998 Adam Pally, T.J. Miller, Thomas Middleditch,Sh... 2014 \n", + "999 Kevin Spacey, Jennifer Garner, Robbie Amell,Ch... 2016 \n", + "\n", + " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore bins \\\n", + "0 121 8.1 757074 333.13 76.0 4 \n", + "1 124 7.0 485820 126.46 65.0 4 \n", + "2 117 7.3 157606 138.12 62.0 4 \n", + "3 108 7.2 60545 270.32 59.0 3 \n", + "4 123 6.2 393727 325.02 40.0 4 \n", + ".. ... ... ... ... ... ... \n", + "995 111 6.2 27585 NaN 45.0 3 \n", + "996 94 5.5 73152 17.54 46.0 3 \n", + "997 98 6.2 70699 58.01 50.0 3 \n", + "998 93 5.6 4881 NaN 22.0 2 \n", + "999 87 5.3 12435 19.64 11.0 3 \n", + "\n", + " Rev_Mins \n", + "0 2.753140 \n", + "1 1.019839 \n", + "2 1.180513 \n", + "3 2.502963 \n", + "4 2.642439 \n", + ".. ... \n", + "995 NaN \n", + "996 0.186596 \n", + "997 0.591939 \n", + "998 NaN \n", + "999 0.225747 \n", + "\n", + "[1000 rows x 14 columns]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['Rev_Mins'] = df['Revenue (Millions)']/df['Runtime (Minutes)']\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "cc71e268", + "metadata": {}, + "outputs": [], + "source": [ + "#Challenge 3\n", + "#We want to create a new ranking where we add 1 point if the genre is thriller \n", + "#but subtract 1 point if the genre is comedy.\n", + "\n", + "def new_rating(Genre,Rating):\n", + " if 'Thriller' in Genre:\n", + " return (Rating+1)\n", + " elif 'Comedy' in Genre:\n", + " return (Rating-1)\n", + " else:\n", + " return Rating" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "9a4d22ce", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)MetascorebinsRev_Minsnew_rating
01Guardians of the GalaxyAction,Adventure,Sci-FiA group of intergalactic criminals are forced ...James GunnChris Pratt, Vin Diesel, Bradley Cooper, Zoe S...20141218.1757074333.1376.042.7531408.1
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.041.0198397.0
23SplitHorror,ThrillerThree girls are kidnapped by a man with a diag...M. Night ShyamalanJames McAvoy, Anya Taylor-Joy, Haley Lu Richar...20161177.3157606138.1262.041.1805138.3
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.032.5029636.2
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.042.6424396.2
................................................
995996Secret in Their EyesCrime,Drama,MysteryA tight-knit team of rising investigators, alo...Billy RayChiwetel Ejiofor, Nicole Kidman, Julia Roberts...20151116.227585NaN45.03NaN6.2
996997Hostel: Part IIHorrorThree American college students studying abroa...Eli RothLauren German, Heather Matarazzo, Bijou Philli...2007945.57315217.5446.030.1865965.5
997998Step Up 2: The StreetsDrama,Music,RomanceRomantic sparks occur between two dance studen...Jon M. ChuRobert Hoffman, Briana Evigan, Cassie Ventura,...2008986.27069958.0150.030.5919396.2
998999Search PartyAdventure,ComedyA pair of friends embark on a mission to reuni...Scot ArmstrongAdam Pally, T.J. Miller, Thomas Middleditch,Sh...2014935.64881NaN22.02NaN4.6
9991000Nine LivesComedy,Family,FantasyA stuffy businessman finds himself trapped ins...Barry SonnenfeldKevin Spacey, Jennifer Garner, Robbie Amell,Ch...2016875.31243519.6411.030.2257474.3
\n", + "

1000 rows × 15 columns

\n", + "
" + ], + "text/plain": [ + " Rank Title Genre \\\n", + "0 1 Guardians of the Galaxy Action,Adventure,Sci-Fi \n", + "1 2 Prometheus Adventure,Mystery,Sci-Fi \n", + "2 3 Split Horror,Thriller \n", + "3 4 Sing Animation,Comedy,Family \n", + "4 5 Suicide Squad Action,Adventure,Fantasy \n", + ".. ... ... ... \n", + "995 996 Secret in Their Eyes Crime,Drama,Mystery \n", + "996 997 Hostel: Part II Horror \n", + "997 998 Step Up 2: The Streets Drama,Music,Romance \n", + "998 999 Search Party Adventure,Comedy \n", + "999 1000 Nine Lives Comedy,Family,Fantasy \n", + "\n", + " Description Director \\\n", + "0 A group of intergalactic criminals are forced ... James Gunn \n", + "1 Following clues to the origin of mankind, a te... Ridley Scott \n", + "2 Three girls are kidnapped by a man with a diag... M. Night Shyamalan \n", + "3 In a city of humanoid animals, a hustling thea... Christophe Lourdelet \n", + "4 A secret government agency recruits some of th... David Ayer \n", + ".. ... ... \n", + "995 A tight-knit team of rising investigators, alo... Billy Ray \n", + "996 Three American college students studying abroa... Eli Roth \n", + "997 Romantic sparks occur between two dance studen... Jon M. Chu \n", + "998 A pair of friends embark on a mission to reuni... Scot Armstrong \n", + "999 A stuffy businessman finds himself trapped ins... Barry Sonnenfeld \n", + "\n", + " Actors Year \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 \n", + ".. ... ... \n", + "995 Chiwetel Ejiofor, Nicole Kidman, Julia Roberts... 2015 \n", + "996 Lauren German, Heather Matarazzo, Bijou Philli... 2007 \n", + "997 Robert Hoffman, Briana Evigan, Cassie Ventura,... 2008 \n", + "998 Adam Pally, T.J. Miller, Thomas Middleditch,Sh... 2014 \n", + "999 Kevin Spacey, Jennifer Garner, Robbie Amell,Ch... 2016 \n", + "\n", + " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore bins \\\n", + "0 121 8.1 757074 333.13 76.0 4 \n", + "1 124 7.0 485820 126.46 65.0 4 \n", + "2 117 7.3 157606 138.12 62.0 4 \n", + "3 108 7.2 60545 270.32 59.0 3 \n", + "4 123 6.2 393727 325.02 40.0 4 \n", + ".. ... ... ... ... ... ... \n", + "995 111 6.2 27585 NaN 45.0 3 \n", + "996 94 5.5 73152 17.54 46.0 3 \n", + "997 98 6.2 70699 58.01 50.0 3 \n", + "998 93 5.6 4881 NaN 22.0 2 \n", + "999 87 5.3 12435 19.64 11.0 3 \n", + "\n", + " Rev_Mins new_rating \n", + "0 2.753140 8.1 \n", + "1 1.019839 7.0 \n", + "2 1.180513 8.3 \n", + "3 2.502963 6.2 \n", + "4 2.642439 6.2 \n", + ".. ... ... \n", + "995 NaN 6.2 \n", + "996 0.186596 5.5 \n", + "997 0.591939 6.2 \n", + "998 NaN 4.6 \n", + "999 0.225747 4.3 \n", + "\n", + "[1000 rows x 15 columns]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['new_rating'] = df.apply(lambda x: new_rating(x['Genre'],x['Rating']),axis=1)\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "c24ce611", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
GenreRatingnew_rating
0Action,Adventure,Sci-Fi8.18.1
1Adventure,Mystery,Sci-Fi7.07.0
2Horror,Thriller7.38.3
3Animation,Comedy,Family7.26.2
4Action,Adventure,Fantasy6.26.2
............
995Crime,Drama,Mystery6.26.2
996Horror5.55.5
997Drama,Music,Romance6.26.2
998Adventure,Comedy5.64.6
999Comedy,Family,Fantasy5.34.3
\n", + "

1000 rows × 3 columns

\n", + "
" + ], + "text/plain": [ + " Genre Rating new_rating\n", + "0 Action,Adventure,Sci-Fi 8.1 8.1\n", + "1 Adventure,Mystery,Sci-Fi 7.0 7.0\n", + "2 Horror,Thriller 7.3 8.3\n", + "3 Animation,Comedy,Family 7.2 6.2\n", + "4 Action,Adventure,Fantasy 6.2 6.2\n", + ".. ... ... ...\n", + "995 Crime,Drama,Mystery 6.2 6.2\n", + "996 Horror 5.5 5.5\n", + "997 Drama,Music,Romance 6.2 6.2\n", + "998 Adventure,Comedy 5.6 4.6\n", + "999 Comedy,Family,Fantasy 5.3 4.3\n", + "\n", + "[1000 rows x 3 columns]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df[['Genre', 'Rating','new_rating']]" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "d9e0d00d", + "metadata": {}, + "outputs": [], + "source": [ + "#Challenge 4\n", + "#We want to know if the sum of the ASCII value of every character of the movie title \n", + "#divided by the number of votes retrieve a prime number\n", + "#...remember, prime numbers are integers.\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "ee6cc56b", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)MetascorebinsRev_Minsnew_ratingtitle_len
01Guardians of the GalaxyAction,Adventure,Sci-FiA group of intergalactic criminals are forced ...James GunnChris Pratt, Vin Diesel, Bradley Cooper, Zoe S...20141218.1757074333.1376.042.7531408.123
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.041.0198397.010
23SplitHorror,ThrillerThree girls are kidnapped by a man with a diag...M. Night ShyamalanJames McAvoy, Anya Taylor-Joy, Haley Lu Richar...20161177.3157606138.1262.041.1805138.35
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.032.5029636.24
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.042.6424396.213
...................................................
995996Secret in Their EyesCrime,Drama,MysteryA tight-knit team of rising investigators, alo...Billy RayChiwetel Ejiofor, Nicole Kidman, Julia Roberts...20151116.227585NaN45.03NaN6.220
996997Hostel: Part IIHorrorThree American college students studying abroa...Eli RothLauren German, Heather Matarazzo, Bijou Philli...2007945.57315217.5446.030.1865965.515
997998Step Up 2: The StreetsDrama,Music,RomanceRomantic sparks occur between two dance studen...Jon M. ChuRobert Hoffman, Briana Evigan, Cassie Ventura,...2008986.27069958.0150.030.5919396.222
998999Search PartyAdventure,ComedyA pair of friends embark on a mission to reuni...Scot ArmstrongAdam Pally, T.J. Miller, Thomas Middleditch,Sh...2014935.64881NaN22.02NaN4.612
9991000Nine LivesComedy,Family,FantasyA stuffy businessman finds himself trapped ins...Barry SonnenfeldKevin Spacey, Jennifer Garner, Robbie Amell,Ch...2016875.31243519.6411.030.2257474.310
\n", + "

1000 rows × 16 columns

\n", + "
" + ], + "text/plain": [ + " Rank Title Genre \\\n", + "0 1 Guardians of the Galaxy Action,Adventure,Sci-Fi \n", + "1 2 Prometheus Adventure,Mystery,Sci-Fi \n", + "2 3 Split Horror,Thriller \n", + "3 4 Sing Animation,Comedy,Family \n", + "4 5 Suicide Squad Action,Adventure,Fantasy \n", + ".. ... ... ... \n", + "995 996 Secret in Their Eyes Crime,Drama,Mystery \n", + "996 997 Hostel: Part II Horror \n", + "997 998 Step Up 2: The Streets Drama,Music,Romance \n", + "998 999 Search Party Adventure,Comedy \n", + "999 1000 Nine Lives Comedy,Family,Fantasy \n", + "\n", + " Description Director \\\n", + "0 A group of intergalactic criminals are forced ... James Gunn \n", + "1 Following clues to the origin of mankind, a te... Ridley Scott \n", + "2 Three girls are kidnapped by a man with a diag... M. Night Shyamalan \n", + "3 In a city of humanoid animals, a hustling thea... Christophe Lourdelet \n", + "4 A secret government agency recruits some of th... David Ayer \n", + ".. ... ... \n", + "995 A tight-knit team of rising investigators, alo... Billy Ray \n", + "996 Three American college students studying abroa... Eli Roth \n", + "997 Romantic sparks occur between two dance studen... Jon M. Chu \n", + "998 A pair of friends embark on a mission to reuni... Scot Armstrong \n", + "999 A stuffy businessman finds himself trapped ins... Barry Sonnenfeld \n", + "\n", + " Actors Year \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 \n", + ".. ... ... \n", + "995 Chiwetel Ejiofor, Nicole Kidman, Julia Roberts... 2015 \n", + "996 Lauren German, Heather Matarazzo, Bijou Philli... 2007 \n", + "997 Robert Hoffman, Briana Evigan, Cassie Ventura,... 2008 \n", + "998 Adam Pally, T.J. Miller, Thomas Middleditch,Sh... 2014 \n", + "999 Kevin Spacey, Jennifer Garner, Robbie Amell,Ch... 2016 \n", + "\n", + " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore bins \\\n", + "0 121 8.1 757074 333.13 76.0 4 \n", + "1 124 7.0 485820 126.46 65.0 4 \n", + "2 117 7.3 157606 138.12 62.0 4 \n", + "3 108 7.2 60545 270.32 59.0 3 \n", + "4 123 6.2 393727 325.02 40.0 4 \n", + ".. ... ... ... ... ... ... \n", + "995 111 6.2 27585 NaN 45.0 3 \n", + "996 94 5.5 73152 17.54 46.0 3 \n", + "997 98 6.2 70699 58.01 50.0 3 \n", + "998 93 5.6 4881 NaN 22.0 2 \n", + "999 87 5.3 12435 19.64 11.0 3 \n", + "\n", + " Rev_Mins new_rating title_len \n", + "0 2.753140 8.1 23 \n", + "1 1.019839 7.0 10 \n", + "2 1.180513 8.3 5 \n", + "3 2.502963 6.2 4 \n", + "4 2.642439 6.2 13 \n", + ".. ... ... ... \n", + "995 NaN 6.2 20 \n", + "996 0.186596 5.5 15 \n", + "997 0.591939 6.2 22 \n", + "998 NaN 4.6 12 \n", + "999 0.225747 4.3 10 \n", + "\n", + "[1000 rows x 16 columns]" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Primero averiguo la longitud del titulo\n", + "df['title_len'] = df['Title'].str.len()\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "7bdf5892", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)MetascorebinsRev_Minsnew_ratingtitle_lenTitle_votes
01Guardians of the GalaxyAction,Adventure,Sci-FiA group of intergalactic criminals are forced ...James GunnChris Pratt, Vin Diesel, Bradley Cooper, Zoe S...20141218.1757074333.1376.042.7531408.1230.000030
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.041.0198397.0100.000021
23SplitHorror,ThrillerThree girls are kidnapped by a man with a diag...M. Night ShyamalanJames McAvoy, Anya Taylor-Joy, Haley Lu Richar...20161177.3157606138.1262.041.1805138.350.000032
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.032.5029636.240.000066
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.042.6424396.2130.000033
......................................................
995996Secret in Their EyesCrime,Drama,MysteryA tight-knit team of rising investigators, alo...Billy RayChiwetel Ejiofor, Nicole Kidman, Julia Roberts...20151116.227585NaN45.03NaN6.2200.000725
996997Hostel: Part IIHorrorThree American college students studying abroa...Eli RothLauren German, Heather Matarazzo, Bijou Philli...2007945.57315217.5446.030.1865965.5150.000205
997998Step Up 2: The StreetsDrama,Music,RomanceRomantic sparks occur between two dance studen...Jon M. ChuRobert Hoffman, Briana Evigan, Cassie Ventura,...2008986.27069958.0150.030.5919396.2220.000311
998999Search PartyAdventure,ComedyA pair of friends embark on a mission to reuni...Scot ArmstrongAdam Pally, T.J. Miller, Thomas Middleditch,Sh...2014935.64881NaN22.02NaN4.6120.002459
9991000Nine LivesComedy,Family,FantasyA stuffy businessman finds himself trapped ins...Barry SonnenfeldKevin Spacey, Jennifer Garner, Robbie Amell,Ch...2016875.31243519.6411.030.2257474.3100.000804
\n", + "

1000 rows × 17 columns

\n", + "
" + ], + "text/plain": [ + " Rank Title Genre \\\n", + "0 1 Guardians of the Galaxy Action,Adventure,Sci-Fi \n", + "1 2 Prometheus Adventure,Mystery,Sci-Fi \n", + "2 3 Split Horror,Thriller \n", + "3 4 Sing Animation,Comedy,Family \n", + "4 5 Suicide Squad Action,Adventure,Fantasy \n", + ".. ... ... ... \n", + "995 996 Secret in Their Eyes Crime,Drama,Mystery \n", + "996 997 Hostel: Part II Horror \n", + "997 998 Step Up 2: The Streets Drama,Music,Romance \n", + "998 999 Search Party Adventure,Comedy \n", + "999 1000 Nine Lives Comedy,Family,Fantasy \n", + "\n", + " Description Director \\\n", + "0 A group of intergalactic criminals are forced ... James Gunn \n", + "1 Following clues to the origin of mankind, a te... Ridley Scott \n", + "2 Three girls are kidnapped by a man with a diag... M. Night Shyamalan \n", + "3 In a city of humanoid animals, a hustling thea... Christophe Lourdelet \n", + "4 A secret government agency recruits some of th... David Ayer \n", + ".. ... ... \n", + "995 A tight-knit team of rising investigators, alo... Billy Ray \n", + "996 Three American college students studying abroa... Eli Roth \n", + "997 Romantic sparks occur between two dance studen... Jon M. Chu \n", + "998 A pair of friends embark on a mission to reuni... Scot Armstrong \n", + "999 A stuffy businessman finds himself trapped ins... Barry Sonnenfeld \n", + "\n", + " Actors Year \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 \n", + ".. ... ... \n", + "995 Chiwetel Ejiofor, Nicole Kidman, Julia Roberts... 2015 \n", + "996 Lauren German, Heather Matarazzo, Bijou Philli... 2007 \n", + "997 Robert Hoffman, Briana Evigan, Cassie Ventura,... 2008 \n", + "998 Adam Pally, T.J. Miller, Thomas Middleditch,Sh... 2014 \n", + "999 Kevin Spacey, Jennifer Garner, Robbie Amell,Ch... 2016 \n", + "\n", + " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore bins \\\n", + "0 121 8.1 757074 333.13 76.0 4 \n", + "1 124 7.0 485820 126.46 65.0 4 \n", + "2 117 7.3 157606 138.12 62.0 4 \n", + "3 108 7.2 60545 270.32 59.0 3 \n", + "4 123 6.2 393727 325.02 40.0 4 \n", + ".. ... ... ... ... ... ... \n", + "995 111 6.2 27585 NaN 45.0 3 \n", + "996 94 5.5 73152 17.54 46.0 3 \n", + "997 98 6.2 70699 58.01 50.0 3 \n", + "998 93 5.6 4881 NaN 22.0 2 \n", + "999 87 5.3 12435 19.64 11.0 3 \n", + "\n", + " Rev_Mins new_rating title_len Title_votes \n", + "0 2.753140 8.1 23 0.000030 \n", + "1 1.019839 7.0 10 0.000021 \n", + "2 1.180513 8.3 5 0.000032 \n", + "3 2.502963 6.2 4 0.000066 \n", + "4 2.642439 6.2 13 0.000033 \n", + ".. ... ... ... ... \n", + "995 NaN 6.2 20 0.000725 \n", + "996 0.186596 5.5 15 0.000205 \n", + "997 0.591939 6.2 22 0.000311 \n", + "998 NaN 4.6 12 0.002459 \n", + "999 0.225747 4.3 10 0.000804 \n", + "\n", + "[1000 rows x 17 columns]" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#después lo dividimos entre el número de votos\n", + "df['Title_votes'] = df['title_len']/df['Votes']\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "a8980f28", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)MetascorebinsRev_Minsnew_ratingtitle_lenTitle_votesPrime_Number
01Guardians of the GalaxyAction,Adventure,Sci-FiA group of intergalactic criminals are forced ...James GunnChris Pratt, Vin Diesel, Bradley Cooper, Zoe S...20141218.1757074333.1376.042.7531408.1230.000030False
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.041.0198397.0100.000021False
23SplitHorror,ThrillerThree girls are kidnapped by a man with a diag...M. Night ShyamalanJames McAvoy, Anya Taylor-Joy, Haley Lu Richar...20161177.3157606138.1262.041.1805138.350.000032False
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.032.5029636.240.000066False
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.042.6424396.2130.000033False
.........................................................
995996Secret in Their EyesCrime,Drama,MysteryA tight-knit team of rising investigators, alo...Billy RayChiwetel Ejiofor, Nicole Kidman, Julia Roberts...20151116.227585NaN45.03NaN6.2200.000725False
996997Hostel: Part IIHorrorThree American college students studying abroa...Eli RothLauren German, Heather Matarazzo, Bijou Philli...2007945.57315217.5446.030.1865965.5150.000205False
997998Step Up 2: The StreetsDrama,Music,RomanceRomantic sparks occur between two dance studen...Jon M. ChuRobert Hoffman, Briana Evigan, Cassie Ventura,...2008986.27069958.0150.030.5919396.2220.000311False
998999Search PartyAdventure,ComedyA pair of friends embark on a mission to reuni...Scot ArmstrongAdam Pally, T.J. Miller, Thomas Middleditch,Sh...2014935.64881NaN22.02NaN4.6120.002459False
9991000Nine LivesComedy,Family,FantasyA stuffy businessman finds himself trapped ins...Barry SonnenfeldKevin Spacey, Jennifer Garner, Robbie Amell,Ch...2016875.31243519.6411.030.2257474.3100.000804False
\n", + "

1000 rows × 18 columns

\n", + "
" + ], + "text/plain": [ + " Rank Title Genre \\\n", + "0 1 Guardians of the Galaxy Action,Adventure,Sci-Fi \n", + "1 2 Prometheus Adventure,Mystery,Sci-Fi \n", + "2 3 Split Horror,Thriller \n", + "3 4 Sing Animation,Comedy,Family \n", + "4 5 Suicide Squad Action,Adventure,Fantasy \n", + ".. ... ... ... \n", + "995 996 Secret in Their Eyes Crime,Drama,Mystery \n", + "996 997 Hostel: Part II Horror \n", + "997 998 Step Up 2: The Streets Drama,Music,Romance \n", + "998 999 Search Party Adventure,Comedy \n", + "999 1000 Nine Lives Comedy,Family,Fantasy \n", + "\n", + " Description Director \\\n", + "0 A group of intergalactic criminals are forced ... James Gunn \n", + "1 Following clues to the origin of mankind, a te... Ridley Scott \n", + "2 Three girls are kidnapped by a man with a diag... M. Night Shyamalan \n", + "3 In a city of humanoid animals, a hustling thea... Christophe Lourdelet \n", + "4 A secret government agency recruits some of th... David Ayer \n", + ".. ... ... \n", + "995 A tight-knit team of rising investigators, alo... Billy Ray \n", + "996 Three American college students studying abroa... Eli Roth \n", + "997 Romantic sparks occur between two dance studen... Jon M. Chu \n", + "998 A pair of friends embark on a mission to reuni... Scot Armstrong \n", + "999 A stuffy businessman finds himself trapped ins... Barry Sonnenfeld \n", + "\n", + " Actors Year \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 \n", + ".. ... ... \n", + "995 Chiwetel Ejiofor, Nicole Kidman, Julia Roberts... 2015 \n", + "996 Lauren German, Heather Matarazzo, Bijou Philli... 2007 \n", + "997 Robert Hoffman, Briana Evigan, Cassie Ventura,... 2008 \n", + "998 Adam Pally, T.J. Miller, Thomas Middleditch,Sh... 2014 \n", + "999 Kevin Spacey, Jennifer Garner, Robbie Amell,Ch... 2016 \n", + "\n", + " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore bins \\\n", + "0 121 8.1 757074 333.13 76.0 4 \n", + "1 124 7.0 485820 126.46 65.0 4 \n", + "2 117 7.3 157606 138.12 62.0 4 \n", + "3 108 7.2 60545 270.32 59.0 3 \n", + "4 123 6.2 393727 325.02 40.0 4 \n", + ".. ... ... ... ... ... ... \n", + "995 111 6.2 27585 NaN 45.0 3 \n", + "996 94 5.5 73152 17.54 46.0 3 \n", + "997 98 6.2 70699 58.01 50.0 3 \n", + "998 93 5.6 4881 NaN 22.0 2 \n", + "999 87 5.3 12435 19.64 11.0 3 \n", + "\n", + " Rev_Mins new_rating title_len Title_votes Prime_Number \n", + "0 2.753140 8.1 23 0.000030 False \n", + "1 1.019839 7.0 10 0.000021 False \n", + "2 1.180513 8.3 5 0.000032 False \n", + "3 2.502963 6.2 4 0.000066 False \n", + "4 2.642439 6.2 13 0.000033 False \n", + ".. ... ... ... ... ... \n", + "995 NaN 6.2 20 0.000725 False \n", + "996 0.186596 5.5 15 0.000205 False \n", + "997 0.591939 6.2 22 0.000311 False \n", + "998 NaN 4.6 12 0.002459 False \n", + "999 0.225747 4.3 10 0.000804 False \n", + "\n", + "[1000 rows x 18 columns]" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Revisamos si hay números primos\n", + "def isprime(n):\n", + " n = abs(int(n))\n", + "\n", + " if n < 2:\n", + " return False\n", + "\n", + " if n == 2: \n", + " return True \n", + " \n", + " if not n & 1: \n", + " return False\n", + "\n", + " for x in range(3, int(n**0.5) + 1, 2):\n", + " if n % x == 0:\n", + " return False\n", + "\n", + " return True\n", + "\n", + "df['Prime_Number'] = df['Title_votes'].apply(isprime)\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "7e6aaf60", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([False])" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Por último revisamos si hay número primos pero todos devuelven falso\n", + "df['Prime_Number'].unique()" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "50d80ac0", + "metadata": {}, + "outputs": [], + "source": [ + "#Feel free to propose your own ranking based in aggregations of at least 3 columns of the dataset.\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "5de08bae", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2016" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['Year'].unique().max()" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "36dfd4b3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 757074, 485820, 157606, 60545, 393727, 56036, 258682,\n", + " 2490, 7188, 192177, 232072, 93103, 323118, 118151,\n", + " 8612, 120259, 211760, 150823, 102061, 340798, 19053,\n", + " 134213, 1115, 38552, 127553, 222, 76193, 523,\n", + " 66540, 112813, 48123, 126030, 275510, 627797, 46165,\n", + " 411656, 1047747, 293732, 122853, 241, 120690, 135095,\n", + " 496, 37033, 279, 395025, 17818, 5103, 164567,\n", + " 987, 661608, 41362, 20221, 321933, 1791916, 49190,\n", + " 121103, 113322, 3739, 137608, 472307, 35870, 102177,\n", + " 244474, 913152, 440209, 39784, 632842, 291, 89849,\n", + " 149791, 78079, 39134, 43977, 296853, 498821, 1045588,\n", + " 959065, 552027, 147717, 1583625, 105081, 865134, 636243,\n", + " 301249, 455169, 27869, 935408, 341170, 162122, 431185,\n", + " 187547, 342429, 106463, 516895, 175067, 34110, 9247,\n", + " 10181, 937414, 108836, 570814, 556097, 7204, 202973,\n", + " 115546, 1954, 117590, 1004, 339797, 3712, 486338,\n", + " 512, 637104, 590595, 30761, 50359, 48969, 192968,\n", + " 157026, 101058, 362093, 53183, 10428, 1222645, 198243,\n", + " 255483, 69651, 153481, 499424, 50953, 109756, 78328,\n", + " 477276, 318051, 200090, 660286, 386102, 855604, 13004,\n", + " 526324, 34184, 246360, 224132, 1039115, 33418, 47694,\n", + " 410249, 442082, 97623, 50853, 735604, 4299, 243230,\n", + " 1973, 97618, 400519, 396714, 291457, 373244, 5926,\n", + " 6946, 552298, 78043, 495106, 361449, 156567, 39723,\n", + " 76935, 308981, 332476, 72778, 2127, 390531, 451894,\n", + " 143069, 337777, 321442, 137203, 368912, 43086, 101781,\n", + " 117018, 1176, 22389, 24003, 11944, 97454, 461509,\n", + " 106364, 27382, 1445, 268282, 22107, 355722, 547368,\n", + " 3799, 459304, 532353, 97082, 471815, 12193, 79855,\n", + " 737719, 70504, 550011, 5435, 26089, 227912, 23713,\n", + " 161396, 114290, 531112, 54679, 443584, 73568, 542362,\n", + " 7044, 1703, 456749, 61098, 283445, 136399, 348551,\n", + " 334867, 19660, 121313, 179450, 268877, 2382, 498879,\n", + " 3305, 247926, 257472, 66766, 377336, 41446, 4895,\n", + " 530881, 96852, 332234, 416689, 1109, 205365, 148949,\n", + " 257426, 382910, 14708, 188017, 557965, 178, 50946,\n", + " 139831, 342183, 330305, 611563, 210349, 422290, 69823,\n", + " 664, 440299, 581518, 21715, 90556, 59312, 53441,\n", + " 75137, 298651, 388447, 2384, 547386, 668651, 432046,\n", + " 52144, 4729, 410125, 280110, 329683, 36312, 591023,\n", + " 492324, 501769, 220236, 110773, 122838, 204874, 30405,\n", + " 150121, 26508, 726, 58782, 226631, 76327, 96,\n", + " 577010, 20514, 34523, 302268, 43929, 400682, 249425,\n", + " 218996, 295554, 67033, 105619, 69509, 57207, 403,\n", + " 193479, 59886, 237221, 103150, 132580, 385598, 385325,\n", + " 199048, 73093, 1263, 81429, 300803, 95960, 616,\n", + " 203096, 319025, 510100, 71149, 37975, 12643, 62885,\n", + " 43085, 34248, 353305, 352801, 207497, 339722, 18201,\n", + " 564364, 115, 271301, 93764, 217464, 452369, 173320,\n", + " 36322, 406219, 92329, 220664, 379088, 96617, 320323,\n", + " 1396, 97679, 33352, 45579, 171970, 59958, 5496,\n", + " 299718, 327838, 221600, 223065, 14248, 417663, 409403,\n", + " 89059, 677044, 194329, 286, 474320, 28326, 702,\n", + " 335531, 38430, 312495, 31776, 7583, 135706, 175673,\n", + " 61812, 137568, 84016, 169083, 45867, 217938, 266508,\n", + " 154647, 101092, 221117, 355362, 220667, 31913, 31194,\n", + " 116112, 102, 114482, 112288, 342355, 86417, 26587,\n", + " 113686, 159830, 240, 93972, 410607, 49041, 40529,\n", + " 226661, 316459, 202380, 74589, 502961, 108306, 252119,\n", + " 35417, 48161, 34546, 164, 202890, 357213, 155010,\n", + " 164208, 8914, 35003, 237887, 100702, 485075, 122185,\n", + " 525700, 43648, 54216, 238789, 48297, 494819, 382459,\n", + " 223, 81301, 58421, 156189, 214825, 220, 181521,\n", + " 94977, 156620, 151409, 4531, 184152, 213764, 52331,\n", + " 309186, 113272, 556666, 58720, 126656, 214994, 202682,\n", + " 192263, 241709, 95119, 182069, 159736, 294553, 51235,\n", + " 8229, 187760, 57602, 357436, 255813, 111558, 556794,\n", + " 199900, 337835, 83941, 297984, 351059, 481274, 56332,\n", + " 278103, 8404, 61, 41642, 226619, 93799, 48400,\n", + " 17584, 55781, 254446, 102954, 84765, 166489, 504039,\n", + " 36091, 241359, 313803, 44553, 94707, 565721, 278379,\n", + " 298913, 228339, 722203, 159364, 77995, 27428, 52636,\n", + " 166872, 107960, 398972, 83625, 622089, 144614, 267820,\n", + " 170897, 47289, 42506, 294950, 137299, 188769, 513744,\n", + " 1356, 24100, 84927, 1830, 36156, 36043, 552,\n", + " 358932, 26461, 318058, 245374, 74674, 12758, 253858,\n", + " 352698, 1024, 143389, 250811, 24761, 198, 7115,\n", + " 137964, 444417, 27042, 177247, 4912, 54787, 10485,\n", + " 324898, 391, 22941, 106381, 17141, 121847, 9187,\n", + " 30074, 30180, 96688, 148504, 90372, 115355, 283282,\n", + " 133113, 171169, 290559, 239772, 47804, 338369, 432461,\n", + " 26521, 68654, 110825, 150353, 159582, 374044, 11900,\n", + " 238206, 44425, 273959, 525646, 44158, 6809, 125129,\n", + " 89885, 60059, 297395, 190673, 114006, 142900, 199860,\n", + " 293941, 182074, 25208, 116118, 122864, 68306, 97141,\n", + " 84083, 63408, 277123, 183926, 181432, 40357, 137684,\n", + " 89791, 1630, 338, 116435, 368556, 33560, 216932,\n", + " 71822, 24387, 130702, 143564, 199973, 21089, 277,\n", + " 29895, 30053, 249877, 66400, 127157, 94069, 78631,\n", + " 144715, 210965, 406540, 7181, 10700, 74886, 151519,\n", + " 261536, 73491, 6683, 776897, 309398, 404884, 195360,\n", + " 50402, 178471, 361105, 110100, 31149, 4304, 3564,\n", + " 595779, 76469, 173, 27006, 44111, 296289, 36300,\n", + " 219916, 30875, 482, 240323, 286722, 178527, 198006,\n", + " 2798, 267872, 54027, 206707, 140151, 5796, 75291,\n", + " 26320, 136323, 168875, 422014, 15514, 47703, 352023,\n", + " 231907, 9285, 233346, 188004, 80415, 57874, 2403,\n", + " 331902, 104953, 16164, 112313, 245144, 534388, 54486,\n", + " 252503, 586669, 157053, 114144, 23540, 10708, 90188,\n", + " 471109, 177602, 19636, 86271, 347567, 1427, 73835,\n", + " 494641, 250012, 106115, 83788, 4754, 208632, 5908,\n", + " 146812, 18437, 335757, 11482, 50388, 92863, 74664,\n", + " 141141, 64557, 96718, 209700, 236500, 65824, 95553,\n", + " 190385, 26088, 127983, 209326, 286543, 309934, 219116,\n", + " 71069, 166342, 201707, 688, 338280, 16163, 259182,\n", + " 4155, 182305, 17439, 124554, 29642, 8998, 144524,\n", + " 254904, 25903, 144779, 313, 3731, 30035, 91684,\n", + " 148943, 92875, 322536, 154400, 353, 187302, 2083,\n", + " 256, 84893, 290056, 91229, 151970, 57826, 156158,\n", + " 154588, 103279, 194236, 351361, 72515, 25928, 347798,\n", + " 2043, 523893, 82701, 199193, 110490, 10871, 9026,\n", + " 499, 29912, 218679, 67196, 128146, 1031, 31370,\n", + " 346154, 378, 11555, 69157, 366138, 50241, 92868,\n", + " 154936, 4370, 129252, 178243, 87887, 304837, 93883,\n", + " 199813, 7091, 196652, 146566, 103681, 221073, 52537,\n", + " 233148, 115751, 4771, 4964, 19309, 142560, 153448,\n", + " 72050, 149779, 285441, 8755, 294010, 91106, 564,\n", + " 13711, 130153, 180105, 5855, 4779, 5715, 1391,\n", + " 160350, 77207, 171356, 16917, 67464, 62719, 225394,\n", + " 38804, 5531, 163144, 8409, 346, 125190, 15232,\n", + " 137117, 95480, 157499, 276347, 77447, 77986, 1066,\n", + " 69659, 198395, 111875, 88829, 208770, 329788, 9993,\n", + " 297093, 55648, 136642, 206793, 119376, 2421, 32310,\n", + " 100890, 6175, 61060, 7402, 20907, 20194, 270429,\n", + " 21569, 59512, 64584, 113599, 101301, 221858, 193579,\n", + " 160592, 152145, 159230, 8365, 125693, 184564, 173919,\n", + " 16361, 253417, 143517, 82874, 75262, 281625, 202,\n", + " 108156, 264480, 102547, 187077, 174553, 61274, 93036,\n", + " 172558, 83976, 27730, 118905, 55243, 237565, 190833,\n", + " 1455, 12361, 269581, 64351, 187004, 17565, 4204,\n", + " 117297, 66265, 33007, 17962, 257395, 19351, 199387,\n", + " 155078, 67801, 31651, 152808, 57921, 246797, 190244,\n", + " 91623, 7475, 3843, 112902, 39380, 92170, 924,\n", + " 2205, 4669, 137502, 60655, 64535, 14689, 279694,\n", + " 50255, 192740, 1292, 62095, 132098, 72533, 93322,\n", + " 3990, 166512, 2417, 92076, 211348, 62403, 65653,\n", + " 173731, 81823, 84158, 192190, 73567, 271940, 10220,\n", + " 88260, 60133, 280, 44227, 1810, 92378, 1210,\n", + " 190855, 37060, 193491, 64513, 108544, 6753, 20966,\n", + " 31634, 2229, 10658, 108772, 12048, 27312, 95172,\n", + " 112729, 21405, 87904, 88000, 33688, 63785, 67637,\n", + " 129708, 102697, 45419, 140900, 164088, 27585, 73152,\n", + " 70699, 4881, 12435], dtype=int64)" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['Votes'].unique()" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "cd2bbaa4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1791916" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['Votes'].unique().max()" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "39c88693", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "61" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['Votes'].unique().min()" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "id": "add76d6b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)MetascorebinsRev_Minsnew_ratingtitle_lenTitle_votesPrime_Number
117118DangalAction,Biography,DramaFormer wrestler Mahavir Singh Phogat and his t...Nitesh TiwariAamir Khan, Sakshi Tanwar, Fatima Sana Shaikh,...20161618.84896911.15NaN30.0692558.860.000123False
9697Kimi no na waAnimation,Drama,FantasyTwo strangers find themselves linked in a biza...Makoto ShinkaiRyûnosuke Kamiki, Mone Kamishiraishi, Ryô Nari...20161068.6341104.6879.030.0441518.6130.000381False
67La La LandComedy,Drama,MusicA jazz pianist falls for an aspiring actress i...Damien ChazelleRyan Gosling, Emma Stone, Rosemarie DeWitt, J....20161288.3258682151.0693.041.1801567.3100.000039False
1617Hacksaw RidgeBiography,Drama,HistoryWWII American Army Medic Desmond T. Doss, who ...Mel GibsonAndrew Garfield, Sam Worthington, Luke Bracey,...20161398.221176067.1271.040.4828788.2130.000061False
145146Ah-ga-ssiDrama,Mystery,RomanceA woman is hired as a handmaiden to a Japanese...Chan-wook ParkMin-hee Kim, Jung-woo Ha, Jin-woong Jo, So-ri ...20161448.1334182.0184.030.0139588.190.000269False
7475ZootopiaAnimation,Adventure,ComedyIn a city of anthropomorphic animals, a rookie...Byron HowardGinnifer Goodwin, Jason Bateman, Idris Elba, J...20161088.1296853341.2678.043.1598157.180.000027False
1819LionBiography,DramaA five-year-old Indian boy gets lost on the st...Garth DavisDev Patel, Nicole Kidman, Rooney Mara, Sunny P...20161188.110206151.6969.040.4380518.140.000039False
273274Sing StreetComedy,Drama,MusicA boy growing up in Dublin during the 1980s es...John CarneyFerdia Walsh-Peelo, Aidan Gillen, Maria Doyle ...20161068.0521443.2379.030.0304727.0110.000211False
184185ForushandeDrama,ThrillerWhile both participating in a production of \"D...Asghar FarhadiTaraneh Alidoosti, Shahab Hosseini, Babak Kari...20161248.0223893.4085.030.0274199.0100.000447False
3334DeadpoolAction,Adventure,ComedyA fast-talking mercenary with a morbid sense o...Tim MillerRyan Reynolds, Morena Baccarin, T.J. Miller, E...20161088.0627797363.0265.043.3612967.080.000013False
\n", + "
" + ], + "text/plain": [ + " Rank Title Genre \\\n", + "117 118 Dangal Action,Biography,Drama \n", + "96 97 Kimi no na wa Animation,Drama,Fantasy \n", + "6 7 La La Land Comedy,Drama,Music \n", + "16 17 Hacksaw Ridge Biography,Drama,History \n", + "145 146 Ah-ga-ssi Drama,Mystery,Romance \n", + "74 75 Zootopia Animation,Adventure,Comedy \n", + "18 19 Lion Biography,Drama \n", + "273 274 Sing Street Comedy,Drama,Music \n", + "184 185 Forushande Drama,Thriller \n", + "33 34 Deadpool Action,Adventure,Comedy \n", + "\n", + " Description Director \\\n", + "117 Former wrestler Mahavir Singh Phogat and his t... Nitesh Tiwari \n", + "96 Two strangers find themselves linked in a biza... Makoto Shinkai \n", + "6 A jazz pianist falls for an aspiring actress i... Damien Chazelle \n", + "16 WWII American Army Medic Desmond T. Doss, who ... Mel Gibson \n", + "145 A woman is hired as a handmaiden to a Japanese... Chan-wook Park \n", + "74 In a city of anthropomorphic animals, a rookie... Byron Howard \n", + "18 A five-year-old Indian boy gets lost on the st... Garth Davis \n", + "273 A boy growing up in Dublin during the 1980s es... John Carney \n", + "184 While both participating in a production of \"D... Asghar Farhadi \n", + "33 A fast-talking mercenary with a morbid sense o... Tim Miller \n", + "\n", + " Actors Year \\\n", + "117 Aamir Khan, Sakshi Tanwar, Fatima Sana Shaikh,... 2016 \n", + "96 Ryûnosuke Kamiki, Mone Kamishiraishi, Ryô Nari... 2016 \n", + "6 Ryan Gosling, Emma Stone, Rosemarie DeWitt, J.... 2016 \n", + "16 Andrew Garfield, Sam Worthington, Luke Bracey,... 2016 \n", + "145 Min-hee Kim, Jung-woo Ha, Jin-woong Jo, So-ri ... 2016 \n", + "74 Ginnifer Goodwin, Jason Bateman, Idris Elba, J... 2016 \n", + "18 Dev Patel, Nicole Kidman, Rooney Mara, Sunny P... 2016 \n", + "273 Ferdia Walsh-Peelo, Aidan Gillen, Maria Doyle ... 2016 \n", + "184 Taraneh Alidoosti, Shahab Hosseini, Babak Kari... 2016 \n", + "33 Ryan Reynolds, Morena Baccarin, T.J. Miller, E... 2016 \n", + "\n", + " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore bins \\\n", + "117 161 8.8 48969 11.15 NaN 3 \n", + "96 106 8.6 34110 4.68 79.0 3 \n", + "6 128 8.3 258682 151.06 93.0 4 \n", + "16 139 8.2 211760 67.12 71.0 4 \n", + "145 144 8.1 33418 2.01 84.0 3 \n", + "74 108 8.1 296853 341.26 78.0 4 \n", + "18 118 8.1 102061 51.69 69.0 4 \n", + "273 106 8.0 52144 3.23 79.0 3 \n", + "184 124 8.0 22389 3.40 85.0 3 \n", + "33 108 8.0 627797 363.02 65.0 4 \n", + "\n", + " Rev_Mins new_rating title_len Title_votes Prime_Number \n", + "117 0.069255 8.8 6 0.000123 False \n", + "96 0.044151 8.6 13 0.000381 False \n", + "6 1.180156 7.3 10 0.000039 False \n", + "16 0.482878 8.2 13 0.000061 False \n", + "145 0.013958 8.1 9 0.000269 False \n", + "74 3.159815 7.1 8 0.000027 False \n", + "18 0.438051 8.1 4 0.000039 False \n", + "273 0.030472 7.0 11 0.000211 False \n", + "184 0.027419 9.0 10 0.000447 False \n", + "33 3.361296 7.0 8 0.000013 False " + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Selecciono solo las peliculas de 2016 \n", + "#Elimino aquellas que no tengan valor de revenue\n", + "#y que me enseñe el top 10 de mayor puntuación \n", + "#siempre y cuando tengan más de 50k votos (resuelto en la siguiente celda)\n", + "\n", + "df2 = df.loc[df['Year'] == 2016]\n", + "df3 = df2.dropna(subset=['Revenue (Millions)'])\n", + "df3.sort_values('Rating', ascending=False).head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "id": "c795b150", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)MetascorebinsRev_Minsnew_ratingtitle_lenTitle_votesPrime_Number
117118DangalAction,Biography,DramaFormer wrestler Mahavir Singh Phogat and his t...Nitesh TiwariAamir Khan, Sakshi Tanwar, Fatima Sana Shaikh,...20161618.84896911.15NaN30.0692558.860.000123False
9697Kimi no na waAnimation,Drama,FantasyTwo strangers find themselves linked in a biza...Makoto ShinkaiRyûnosuke Kamiki, Mone Kamishiraishi, Ryô Nari...20161068.6341104.6879.030.0441518.6130.000381False
67La La LandComedy,Drama,MusicA jazz pianist falls for an aspiring actress i...Damien ChazelleRyan Gosling, Emma Stone, Rosemarie DeWitt, J....20161288.3258682151.0693.041.1801567.3100.000039False
1617Hacksaw RidgeBiography,Drama,HistoryWWII American Army Medic Desmond T. Doss, who ...Mel GibsonAndrew Garfield, Sam Worthington, Luke Bracey,...20161398.221176067.1271.040.4828788.2130.000061False
145146Ah-ga-ssiDrama,Mystery,RomanceA woman is hired as a handmaiden to a Japanese...Chan-wook ParkMin-hee Kim, Jung-woo Ha, Jin-woong Jo, So-ri ...20161448.1334182.0184.030.0139588.190.000269False
7475ZootopiaAnimation,Adventure,ComedyIn a city of anthropomorphic animals, a rookie...Byron HowardGinnifer Goodwin, Jason Bateman, Idris Elba, J...20161088.1296853341.2678.043.1598157.180.000027False
1819LionBiography,DramaA five-year-old Indian boy gets lost on the st...Garth DavisDev Patel, Nicole Kidman, Rooney Mara, Sunny P...20161188.110206151.6969.040.4380518.140.000039False
273274Sing StreetComedy,Drama,MusicA boy growing up in Dublin during the 1980s es...John CarneyFerdia Walsh-Peelo, Aidan Gillen, Maria Doyle ...20161068.0521443.2379.030.0304727.0110.000211False
184185ForushandeDrama,ThrillerWhile both participating in a production of \"D...Asghar FarhadiTaraneh Alidoosti, Shahab Hosseini, Babak Kari...20161248.0223893.4085.030.0274199.0100.000447False
3334DeadpoolAction,Adventure,ComedyA fast-talking mercenary with a morbid sense o...Tim MillerRyan Reynolds, Morena Baccarin, T.J. Miller, E...20161088.0627797363.0265.043.3612967.080.000013False
\n", + "
" + ], + "text/plain": [ + " Rank Title Genre \\\n", + "117 118 Dangal Action,Biography,Drama \n", + "96 97 Kimi no na wa Animation,Drama,Fantasy \n", + "6 7 La La Land Comedy,Drama,Music \n", + "16 17 Hacksaw Ridge Biography,Drama,History \n", + "145 146 Ah-ga-ssi Drama,Mystery,Romance \n", + "74 75 Zootopia Animation,Adventure,Comedy \n", + "18 19 Lion Biography,Drama \n", + "273 274 Sing Street Comedy,Drama,Music \n", + "184 185 Forushande Drama,Thriller \n", + "33 34 Deadpool Action,Adventure,Comedy \n", + "\n", + " Description Director \\\n", + "117 Former wrestler Mahavir Singh Phogat and his t... Nitesh Tiwari \n", + "96 Two strangers find themselves linked in a biza... Makoto Shinkai \n", + "6 A jazz pianist falls for an aspiring actress i... Damien Chazelle \n", + "16 WWII American Army Medic Desmond T. Doss, who ... Mel Gibson \n", + "145 A woman is hired as a handmaiden to a Japanese... Chan-wook Park \n", + "74 In a city of anthropomorphic animals, a rookie... Byron Howard \n", + "18 A five-year-old Indian boy gets lost on the st... Garth Davis \n", + "273 A boy growing up in Dublin during the 1980s es... John Carney \n", + "184 While both participating in a production of \"D... Asghar Farhadi \n", + "33 A fast-talking mercenary with a morbid sense o... Tim Miller \n", + "\n", + " Actors Year \\\n", + "117 Aamir Khan, Sakshi Tanwar, Fatima Sana Shaikh,... 2016 \n", + "96 Ryûnosuke Kamiki, Mone Kamishiraishi, Ryô Nari... 2016 \n", + "6 Ryan Gosling, Emma Stone, Rosemarie DeWitt, J.... 2016 \n", + "16 Andrew Garfield, Sam Worthington, Luke Bracey,... 2016 \n", + "145 Min-hee Kim, Jung-woo Ha, Jin-woong Jo, So-ri ... 2016 \n", + "74 Ginnifer Goodwin, Jason Bateman, Idris Elba, J... 2016 \n", + "18 Dev Patel, Nicole Kidman, Rooney Mara, Sunny P... 2016 \n", + "273 Ferdia Walsh-Peelo, Aidan Gillen, Maria Doyle ... 2016 \n", + "184 Taraneh Alidoosti, Shahab Hosseini, Babak Kari... 2016 \n", + "33 Ryan Reynolds, Morena Baccarin, T.J. Miller, E... 2016 \n", + "\n", + " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore bins \\\n", + "117 161 8.8 48969 11.15 NaN 3 \n", + "96 106 8.6 34110 4.68 79.0 3 \n", + "6 128 8.3 258682 151.06 93.0 4 \n", + "16 139 8.2 211760 67.12 71.0 4 \n", + "145 144 8.1 33418 2.01 84.0 3 \n", + "74 108 8.1 296853 341.26 78.0 4 \n", + "18 118 8.1 102061 51.69 69.0 4 \n", + "273 106 8.0 52144 3.23 79.0 3 \n", + "184 124 8.0 22389 3.40 85.0 3 \n", + "33 108 8.0 627797 363.02 65.0 4 \n", + "\n", + " Rev_Mins new_rating title_len Title_votes Prime_Number \n", + "117 0.069255 8.8 6 0.000123 False \n", + "96 0.044151 8.6 13 0.000381 False \n", + "6 1.180156 7.3 10 0.000039 False \n", + "16 0.482878 8.2 13 0.000061 False \n", + "145 0.013958 8.1 9 0.000269 False \n", + "74 3.159815 7.1 8 0.000027 False \n", + "18 0.438051 8.1 4 0.000039 False \n", + "273 0.030472 7.0 11 0.000211 False \n", + "184 0.027419 9.0 10 0.000447 False \n", + "33 3.361296 7.0 8 0.000013 False " + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df4 = df3.sort_values('Rating', ascending=False).head(10)\n", + "df4.loc[(df4['Votes'] > 10000)]" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python [conda env:m1_env]", + "language": "python", + "name": "conda-env-m1_env-py" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.16" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}