diff --git a/notebooks/your_code_here.ipynb b/notebooks/your_code_here.ipynb index f60a09e..51b5a4d 100644 --- a/notebooks/your_code_here.ipynb +++ b/notebooks/your_code_here.ipynb @@ -12,46 +12,2095 @@ }, { "cell_type": "code", - "execution_count": 1, - "id": "ace6da70", + "execution_count": 34, + "id": "d3c3dd76", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "import hashlib as hl" + ] + }, + { + "cell_type": "markdown", + "id": "5aeb3f32", + "metadata": {}, + "source": [ + "# Challenge 1" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "0969ac94", + "metadata": {}, + "outputs": [], + "source": [ + "df = pd.read_csv(\"../data/input/IMDB-Movie-Data.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "a8c28cc2", + "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", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)Metascore
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.0
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.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.0
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.0
\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", + " 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", + " Actors Year Runtime (Minutes) \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 121 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 124 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 117 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 108 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 123 \n", + "\n", + " Rating Votes Revenue (Millions) Metascore \n", + "0 8.1 757074 333.13 76.0 \n", + "1 7.0 485820 126.46 65.0 \n", + "2 7.3 157606 138.12 62.0 \n", + "3 7.2 60545 270.32 59.0 \n", + "4 6.2 393727 325.02 40.0 " + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "9cd4dbb6", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The Zen of Python, by Tim Peters\n", - "\n", - "Beautiful is better than ugly.\n", - "Explicit is better than implicit.\n", - "Simple is better than complex.\n", - "Complex is better than complicated.\n", - "Flat is better than nested.\n", - "Sparse is better than dense.\n", - "Readability counts.\n", - "Special cases aren't special enough to break the rules.\n", - "Although practicality beats purity.\n", - "Errors should never pass silently.\n", - "Unless explicitly silenced.\n", - "In the face of ambiguity, refuse the temptation to guess.\n", - "There should be one-- and preferably only one --obvious way to do it.\n", - "Although that way may not be obvious at first unless you're Dutch.\n", - "Now is better than never.\n", - "Although never is often better than *right* now.\n", - "If the implementation is hard to explain, it's a bad idea.\n", - "If the implementation is easy to explain, it may be a good idea.\n", - "Namespaces are one honking great idea -- let's do more of those!\n" + "\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": [ - "import this" + "df.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "dcb80b80", + "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", + "
RankYearRuntime (Minutes)RatingVotesRevenue (Millions)Metascore
count1000.0000001000.0000001000.0000001000.0000001.000000e+03872.000000936.000000
mean500.5000002012.783000113.1720006.7232001.698083e+0582.95637658.985043
std288.8194363.20596218.8109080.9454291.887626e+05103.25354017.194757
min1.0000002006.00000066.0000001.9000006.100000e+010.00000011.000000
25%250.7500002010.000000100.0000006.2000003.630900e+0413.27000047.000000
50%500.5000002014.000000111.0000006.8000001.107990e+0547.98500059.500000
75%750.2500002016.000000123.0000007.4000002.399098e+05113.71500072.000000
max1000.0000002016.000000191.0000009.0000001.791916e+06936.630000100.000000
\n", + "
" + ], + "text/plain": [ + " Rank Year Runtime (Minutes) Rating Votes \\\n", + "count 1000.000000 1000.000000 1000.000000 1000.000000 1.000000e+03 \n", + "mean 500.500000 2012.783000 113.172000 6.723200 1.698083e+05 \n", + "std 288.819436 3.205962 18.810908 0.945429 1.887626e+05 \n", + "min 1.000000 2006.000000 66.000000 1.900000 6.100000e+01 \n", + "25% 250.750000 2010.000000 100.000000 6.200000 3.630900e+04 \n", + "50% 500.500000 2014.000000 111.000000 6.800000 1.107990e+05 \n", + "75% 750.250000 2016.000000 123.000000 7.400000 2.399098e+05 \n", + "max 1000.000000 2016.000000 191.000000 9.000000 1.791916e+06 \n", + "\n", + " Revenue (Millions) Metascore \n", + "count 872.000000 936.000000 \n", + "mean 82.956376 58.985043 \n", + "std 103.253540 17.194757 \n", + "min 0.000000 11.000000 \n", + "25% 13.270000 47.000000 \n", + "50% 47.985000 59.500000 \n", + "75% 113.715000 72.000000 \n", + "max 936.630000 100.000000 " + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "0764cdfb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'cat_1'" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def number_of_votes(votes):\n", + " if votes >= 0 and votes <= 999:\n", + " return('cat_1')\n", + "number_of_votes(100)" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "3dab33ca", + "metadata": {}, + "outputs": [], + "source": [ + "def number_of_votes(votes):\n", + " if votes >= 0 and votes <= 999:\n", + " return('cat_1')\n", + " elif votes >= 1000 and votes <= 9999:\n", + " return('cat_2')\n", + " elif votes >= 10000 and votes <= 99999:\n", + " return('cat_3')\n", + " elif votes >= 100000 and votes <= 999999:\n", + " return('cat_4')\n", + " elif votes >= 1000000:\n", + " return('cat_5')" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "95520894", + "metadata": {}, + "outputs": [], + "source": [ + "df[\"bin\"] = df.apply(lambda row: number_of_votes(row[\"Votes\"]), axis = 1)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "68994ec7", + "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", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)Metascorebin
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.0cat_4
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.0cat_4
23SplitHorror,ThrillerThree girls are kidnapped by a man with a diag...M. Night ShyamalanJames McAvoy, Anya Taylor-Joy, Haley Lu Richar...20161177.3157606138.1262.0cat_4
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0cat_3
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.0cat_4
\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", + " 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", + " Actors Year Runtime (Minutes) \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 121 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 124 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 117 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 108 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 123 \n", + "\n", + " Rating Votes Revenue (Millions) Metascore bin \n", + "0 8.1 757074 333.13 76.0 cat_4 \n", + "1 7.0 485820 126.46 65.0 cat_4 \n", + "2 7.3 157606 138.12 62.0 cat_4 \n", + "3 7.2 60545 270.32 59.0 cat_3 \n", + "4 6.2 393727 325.02 40.0 cat_4 " + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "markdown", + "id": "c16eecc5", + "metadata": {}, + "source": [ + "# Challenge 2" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "a9480ec8", + "metadata": {}, + "outputs": [], + "source": [ + "df[\"revenue\"] = df.apply(lambda row: row[\"Revenue (Millions)\"] / row[\"Runtime (Minutes)\"], axis = 1)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "id": "a58b5ae0", + "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", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)Metascorebinrevenue
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.0cat_42.753140
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.0cat_41.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.0cat_41.180513
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0cat_32.502963
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.0cat_42.642439
\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", + " 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", + " Actors Year Runtime (Minutes) \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 121 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 124 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 117 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 108 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 123 \n", + "\n", + " Rating Votes Revenue (Millions) Metascore bin revenue \n", + "0 8.1 757074 333.13 76.0 cat_4 2.753140 \n", + "1 7.0 485820 126.46 65.0 cat_4 1.019839 \n", + "2 7.3 157606 138.12 62.0 cat_4 1.180513 \n", + "3 7.2 60545 270.32 59.0 cat_3 2.502963 \n", + "4 6.2 393727 325.02 40.0 cat_4 2.642439 " + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "markdown", + "id": "5d4fa04e", + "metadata": {}, + "source": [ + "# Challenge 3" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "ef5149e1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'\"def new_rating(genre):\\n rate = 0\\n if \\'thriller\\' in genre.lower():\\n rate += 1\\n elif genre == \\'comedy\\':\\n rate -= 1\\n return rate\\n\\nnew_rating(\\'comedy\\')\\n '" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"\"\"\"def new_rating(genre):\n", + " rate = 0\n", + " if 'thriller' in genre.lower():\n", + " rate += 1\n", + " elif genre == 'comedy':\n", + " rate -= 1\n", + " return rate\n", + "\n", + "new_rating('comedy')\n", + " \"\"\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "id": "da9894ed", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def new_rating(genre):\n", + " rate = 0\n", + " if 'thriller' in genre.lower():\n", + " rate += 1\n", + " elif 'comedy' in genre.lower():\n", + " rate -= 1\n", + " return rate\n", + "\n", + "new_rating('comdedydlkfñasklf')" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "16659459", + "metadata": {}, + "outputs": [], + "source": [ + "df[\"new_rating\"] = df.apply(lambda row: new_rating(row[\"Genre\"]) + row['Rating'], axis = 1)" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "id": "b0d913a8", + "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", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)Metascorebinrevenuenew_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.0cat_42.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.0cat_41.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.0cat_41.1805138.3
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0cat_32.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.0cat_42.6424396.2
\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", + " 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", + " Actors Year Runtime (Minutes) \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 121 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 124 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 117 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 108 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 123 \n", + "\n", + " Rating Votes Revenue (Millions) Metascore bin revenue new_rating \n", + "0 8.1 757074 333.13 76.0 cat_4 2.753140 8.1 \n", + "1 7.0 485820 126.46 65.0 cat_4 1.019839 7.0 \n", + "2 7.3 157606 138.12 62.0 cat_4 1.180513 8.3 \n", + "3 7.2 60545 270.32 59.0 cat_3 2.502963 6.2 \n", + "4 6.2 393727 325.02 40.0 cat_4 2.642439 6.2 " + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "markdown", + "id": "65b0c6c9", + "metadata": {}, + "source": [ + "# Challenge 4\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "0d2f5007", + "metadata": {}, + "outputs": [], + "source": [ + "#We want to know whether the integer part of the number resulting\n", + "#from the sum of the ASCII value of every character of the movie title divided by the number of votes,\n", + "#is a prime number (remember that prime numbers are integers)." + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "id": "7a41fddc", + "metadata": {}, + "outputs": [], + "source": [ + "def prime_num(num):\n", + " for n in range (2,num):\n", + " if num % n == 0:\n", + " return False\n", + " return True" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "1d6c855e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "prime_num(20)" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "841138a1", + "metadata": {}, + "outputs": [], + "source": [ + "def ascii_value(name,votes):\n", + " value = 0\n", + " for character in name:\n", + " value= ord(character)\n", + " votes_per_value = int(votes/value)\n", + " return prime_num(votes_per_value)" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "id": "7dad8a36", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ascii_value('Prometheus',485820)" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "cdaef37f", + "metadata": {}, + "outputs": [], + "source": [ + "df['votes_per_value'] = df.apply(lambda row: ascii_value(row['Title'], row['Votes']), axis = 1)" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "id": "89c19730", + "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", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)Metascorebinrevenuenew_ratingvotes_per_value
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.0cat_42.7531408.1False
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.0cat_41.0198397.0False
23SplitHorror,ThrillerThree girls are kidnapped by a man with a diag...M. Night ShyamalanJames McAvoy, Anya Taylor-Joy, Haley Lu Richar...20161177.3157606138.1262.0cat_41.1805138.3False
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0cat_32.5029636.2True
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.0cat_42.6424396.2False
\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", + " 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", + " Actors Year Runtime (Minutes) \\\n", + "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 121 \n", + "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 124 \n", + "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 117 \n", + "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 108 \n", + "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 123 \n", + "\n", + " Rating Votes Revenue (Millions) Metascore bin revenue new_rating \\\n", + "0 8.1 757074 333.13 76.0 cat_4 2.753140 8.1 \n", + "1 7.0 485820 126.46 65.0 cat_4 1.019839 7.0 \n", + "2 7.3 157606 138.12 62.0 cat_4 1.180513 8.3 \n", + "3 7.2 60545 270.32 59.0 cat_3 2.502963 6.2 \n", + "4 6.2 393727 325.02 40.0 cat_4 2.642439 6.2 \n", + "\n", + " votes_per_value \n", + "0 False \n", + "1 False \n", + "2 False \n", + "3 True \n", + "4 False " + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "markdown", + "id": "c078ae6e", + "metadata": {}, + "source": [ + "# Challenge 5" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "id": "3e80fc75", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "82.95637614678898\n", + "6.723199999999999\n", + "169808.255\n" + ] + } + ], + "source": [ + "#Feel free to propose your own ranking based in aggregations of at least 3 columns of the dataset.\n", + "# Im going to make a ranking based on Revenue, rating and votes\n", + "mean_revenue = df['Revenue (Millions)'].mean()\n", + "mean_rating = df['Rating'].mean()\n", + "mean_votes = df['Votes'].mean()\n", + "print(mean_revenue)\n", + "print(mean_rating)\n", + "print(mean_votes)" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "id": "9a96b168", + "metadata": {}, + "outputs": [], + "source": [ + "def fantasy_rank(revenue,rating,votes):\n", + " return ((revenue - mean_revenue) * 0.33) + ((rating - mean_rating) * 0.33) + ((votes - mean_votes) * 0.33)" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "id": "f08a63ee", + "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)Metascorebinrevenuenew_ratingvotes_per_valueFantasy_Rank
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.0cat_42.7531408.1False193880.70749
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.0cat_41.0198397.0False104298.32339
23SplitHorror,ThrillerThree girls are kidnapped by a man with a diag...M. Night ShyamalanJames McAvoy, Anya Taylor-Joy, Haley Lu Richar...20161177.3157606138.1262.0cat_41.1805138.3False-4008.34981
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0cat_32.5029636.2True-35994.88681
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.0cat_42.6424396.2False73972.89419
......................................................
995996Secret in Their EyesCrime,Drama,MysteryA tight-knit team of rising investigators, alo...Billy RayChiwetel Ejiofor, Nicole Kidman, Julia Roberts...20151116.227585NaN45.0cat_3NaN6.2TrueNaN
996997Hostel: Part IIHorrorThree American college students studying abroa...Eli RothLauren German, Heather Matarazzo, Bijou Philli...2007945.57315217.5446.0cat_30.1865965.5False-31918.55521
997998Step Up 2: The StreetsDrama,Music,RomanceRomantic sparks occur between two dance studen...Jon M. ChuRobert Hoffman, Briana Evigan, Cassie Ventura,...2008986.27069958.0150.0cat_30.5919396.2False-32714.45911
998999Search PartyAdventure,ComedyA pair of friends embark on a mission to reuni...Scot ArmstrongAdam Pally, T.J. Miller, Thomas Middleditch,Sh...2014935.64881NaN22.0cat_2NaN4.6FalseNaN
9991000Nine LivesComedy,Family,FantasyA stuffy businessman finds himself trapped ins...Barry SonnenfeldKevin Spacey, Jennifer Garner, Robbie Amell,Ch...2016875.31243519.6411.0cat_30.2257474.3False-51954.53821
\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 bin \\\n", + "0 121 8.1 757074 333.13 76.0 cat_4 \n", + "1 124 7.0 485820 126.46 65.0 cat_4 \n", + "2 117 7.3 157606 138.12 62.0 cat_4 \n", + "3 108 7.2 60545 270.32 59.0 cat_3 \n", + "4 123 6.2 393727 325.02 40.0 cat_4 \n", + ".. ... ... ... ... ... ... \n", + "995 111 6.2 27585 NaN 45.0 cat_3 \n", + "996 94 5.5 73152 17.54 46.0 cat_3 \n", + "997 98 6.2 70699 58.01 50.0 cat_3 \n", + "998 93 5.6 4881 NaN 22.0 cat_2 \n", + "999 87 5.3 12435 19.64 11.0 cat_3 \n", + "\n", + " revenue new_rating votes_per_value Fantasy_Rank \n", + "0 2.753140 8.1 False 193880.70749 \n", + "1 1.019839 7.0 False 104298.32339 \n", + "2 1.180513 8.3 False -4008.34981 \n", + "3 2.502963 6.2 True -35994.88681 \n", + "4 2.642439 6.2 False 73972.89419 \n", + ".. ... ... ... ... \n", + "995 NaN 6.2 True NaN \n", + "996 0.186596 5.5 False -31918.55521 \n", + "997 0.591939 6.2 False -32714.45911 \n", + "998 NaN 4.6 False NaN \n", + "999 0.225747 4.3 False -51954.53821 \n", + "\n", + "[1000 rows x 17 columns]" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['Fantasy_Rank'] = df.apply(lambda row : fantasy_rank(row['Revenue (Millions)'], row['Rating'], row['Votes']),axis = 1)\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "id": "9a2fb161", + "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)Metascorebinrevenuenew_ratingvotes_per_valueFantasy_Rank
5455The Dark KnightAction,Crime,DramaWhen the menace known as the Joker wreaks havo...Christopher NolanChristian Bale, Heath Ledger, Aaron Eckhart,Mi...20081529.01791916533.3282.0cat_53.5086849.0False535444.92719
8081InceptionAction,Adventure,Sci-FiA thief, who steals corporate secrets through ...Christopher NolanLeonardo DiCaprio, Joseph Gordon-Levitt, Ellen...20101488.81583625292.5774.0cat_51.9768248.8False466629.38369
124125The Dark Knight RisesAction,ThrillerEight years after the Joker's reign of anarchy...Christopher NolanChristian Bale, Tom Hardy, Anne Hathaway,Gary ...20121648.51222645448.1378.0cat_52.7325009.5True347557.21949
3637InterstellarAdventure,Drama,Sci-FiA team of explorers travel through a wormhole ...Christopher NolanMatthew McConaughey, Anne Hathaway, Jessica Ch...20141698.61047747187.9974.0cat_51.1123678.6False289755.06629
7677The AvengersAction,Sci-FiEarth's mightiest heroes must come together an...Joss WhedonRobert Downey Jr., Chris Evans, Scarlett Johan...20121438.11045588623.2869.0cat_54.3586018.1False289186.07699
......................................................
977978Amateur NightComedyGuy Carter is an award-winning graduate studen...Lisa AddarioJason Biggs, Janet Montgomery,Ashley Tisdale, ...2016925.02229NaN38.0cat_2NaN4.0TrueNaN
978979It's Only the End of the WorldDramaLouis (Gaspard Ulliel), a terminally ill write...Xavier DolanNathalie Baye, Vincent Cassel, Marion Cotillar...2016977.010658NaN48.0cat_3NaN7.0FalseNaN
988989MartyrsHorrorA young woman's quest for revenge against the ...Pascal LaugierMorjana Alaoui, Mylène Jampanoï, Catherine Bég...2008997.163785NaN89.0cat_3NaN7.1FalseNaN
995996Secret in Their EyesCrime,Drama,MysteryA tight-knit team of rising investigators, alo...Billy RayChiwetel Ejiofor, Nicole Kidman, Julia Roberts...20151116.227585NaN45.0cat_3NaN6.2TrueNaN
998999Search PartyAdventure,ComedyA pair of friends embark on a mission to reuni...Scot ArmstrongAdam Pally, T.J. Miller, Thomas Middleditch,Sh...2014935.64881NaN22.0cat_2NaN4.6FalseNaN
\n", + "

1000 rows × 17 columns

\n", + "
" + ], + "text/plain": [ + " Rank Title Genre \\\n", + "54 55 The Dark Knight Action,Crime,Drama \n", + "80 81 Inception Action,Adventure,Sci-Fi \n", + "124 125 The Dark Knight Rises Action,Thriller \n", + "36 37 Interstellar Adventure,Drama,Sci-Fi \n", + "76 77 The Avengers Action,Sci-Fi \n", + ".. ... ... ... \n", + "977 978 Amateur Night Comedy \n", + "978 979 It's Only the End of the World Drama \n", + "988 989 Martyrs Horror \n", + "995 996 Secret in Their Eyes Crime,Drama,Mystery \n", + "998 999 Search Party Adventure,Comedy \n", + "\n", + " Description Director \\\n", + "54 When the menace known as the Joker wreaks havo... Christopher Nolan \n", + "80 A thief, who steals corporate secrets through ... Christopher Nolan \n", + "124 Eight years after the Joker's reign of anarchy... Christopher Nolan \n", + "36 A team of explorers travel through a wormhole ... Christopher Nolan \n", + "76 Earth's mightiest heroes must come together an... Joss Whedon \n", + ".. ... ... \n", + "977 Guy Carter is an award-winning graduate studen... Lisa Addario \n", + "978 Louis (Gaspard Ulliel), a terminally ill write... Xavier Dolan \n", + "988 A young woman's quest for revenge against the ... Pascal Laugier \n", + "995 A tight-knit team of rising investigators, alo... Billy Ray \n", + "998 A pair of friends embark on a mission to reuni... Scot Armstrong \n", + "\n", + " Actors Year \\\n", + "54 Christian Bale, Heath Ledger, Aaron Eckhart,Mi... 2008 \n", + "80 Leonardo DiCaprio, Joseph Gordon-Levitt, Ellen... 2010 \n", + "124 Christian Bale, Tom Hardy, Anne Hathaway,Gary ... 2012 \n", + "36 Matthew McConaughey, Anne Hathaway, Jessica Ch... 2014 \n", + "76 Robert Downey Jr., Chris Evans, Scarlett Johan... 2012 \n", + ".. ... ... \n", + "977 Jason Biggs, Janet Montgomery,Ashley Tisdale, ... 2016 \n", + "978 Nathalie Baye, Vincent Cassel, Marion Cotillar... 2016 \n", + "988 Morjana Alaoui, Mylène Jampanoï, Catherine Bég... 2008 \n", + "995 Chiwetel Ejiofor, Nicole Kidman, Julia Roberts... 2015 \n", + "998 Adam Pally, T.J. Miller, Thomas Middleditch,Sh... 2014 \n", + "\n", + " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore bin \\\n", + "54 152 9.0 1791916 533.32 82.0 cat_5 \n", + "80 148 8.8 1583625 292.57 74.0 cat_5 \n", + "124 164 8.5 1222645 448.13 78.0 cat_5 \n", + "36 169 8.6 1047747 187.99 74.0 cat_5 \n", + "76 143 8.1 1045588 623.28 69.0 cat_5 \n", + ".. ... ... ... ... ... ... \n", + "977 92 5.0 2229 NaN 38.0 cat_2 \n", + "978 97 7.0 10658 NaN 48.0 cat_3 \n", + "988 99 7.1 63785 NaN 89.0 cat_3 \n", + "995 111 6.2 27585 NaN 45.0 cat_3 \n", + "998 93 5.6 4881 NaN 22.0 cat_2 \n", + "\n", + " revenue new_rating votes_per_value Fantasy_Rank \n", + "54 3.508684 9.0 False 535444.92719 \n", + "80 1.976824 8.8 False 466629.38369 \n", + "124 2.732500 9.5 True 347557.21949 \n", + "36 1.112367 8.6 False 289755.06629 \n", + "76 4.358601 8.1 False 289186.07699 \n", + ".. ... ... ... ... \n", + "977 NaN 4.0 True NaN \n", + "978 NaN 7.0 False NaN \n", + "988 NaN 7.1 False NaN \n", + "995 NaN 6.2 True NaN \n", + "998 NaN 4.6 False NaN \n", + "\n", + "[1000 rows x 17 columns]" + ] + }, + "execution_count": 81, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.sort_values(by = 'Fantasy_Rank', ascending = False)" ] }, { "cell_type": "code", "execution_count": null, - "id": "d3c3dd76", + "id": "4ce89f8e", "metadata": {}, "outputs": [], "source": [] @@ -59,9 +2108,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:.conda-m1_env]", + "display_name": "Python (m1_env)", "language": "python", - "name": "conda-env-.conda-m1_env-py" + "name": "m1_env" }, "language_info": { "codemirror_mode": { @@ -73,7 +2122,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.10.13" } }, "nbformat": 4,