From 320df0b97199dda8a762e1e81e4216af8df6b65d Mon Sep 17 00:00:00 2001 From: SilviaAlconGarrido Date: Sat, 28 Oct 2023 14:24:32 +0200 Subject: [PATCH 1/4] Frist commit --- notebooks/your_code_here.ipynb | 311 ++++++++++++++++++++++++++++++--- 1 file changed, 285 insertions(+), 26 deletions(-) diff --git a/notebooks/your_code_here.ipynb b/notebooks/your_code_here.ipynb index f60a09e..85d08af 100644 --- a/notebooks/your_code_here.ipynb +++ b/notebooks/your_code_here.ipynb @@ -15,43 +15,302 @@ "execution_count": 1, "id": "ace6da70", "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "d3c3dd76", + "metadata": {}, + "outputs": [], + "source": [ + "df_movies = pd.read_csv('../data/input/IMDB-Movie-Data.csv')" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "f1c81c62", + "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": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_movies.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "c53ce69f", + "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_movies.info()" ] }, { "cell_type": "code", "execution_count": null, - "id": "d3c3dd76", + "id": "311cfa09", + "metadata": {}, + "outputs": [], + "source": [ + "def bins(votes):\n", + " if x >= 0 and x <= 999:\n", + " return'cat 1'\n", + " elif votes = 1000 >= 9999\n", + " print('cat 2')\n", + " elif votes = 10000 >= 99999\n", + " print('cat 3')\n", + " elif votes = 100000 >= 999999 \n", + " print('cat 4')\n", + " elif votes >= 1000000\n", + " print('cat 5')\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "a6933b5d", + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'bins' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[5], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#challenge 1\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;66;03m#df_movies_bins['bin'] = df_movies['Votes'].apply(bins)\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m df_movies_bins[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbin\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[43mdf_movies\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapply\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43;01mlambda\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mrow\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mbins\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrow\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mVotes\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 4\u001b[0m df_movies_bins\u001b[38;5;241m.\u001b[39mhead()\n", + "File \u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/frame.py:9423\u001b[0m, in \u001b[0;36mDataFrame.apply\u001b[0;34m(self, func, axis, raw, result_type, args, **kwargs)\u001b[0m\n\u001b[1;32m 9412\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpandas\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcore\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mapply\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m frame_apply\n\u001b[1;32m 9414\u001b[0m op \u001b[38;5;241m=\u001b[39m frame_apply(\n\u001b[1;32m 9415\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 9416\u001b[0m func\u001b[38;5;241m=\u001b[39mfunc,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 9421\u001b[0m kwargs\u001b[38;5;241m=\u001b[39mkwargs,\n\u001b[1;32m 9422\u001b[0m )\n\u001b[0;32m-> 9423\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mop\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapply\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39m__finalize__(\u001b[38;5;28mself\u001b[39m, method\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mapply\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py:678\u001b[0m, in \u001b[0;36mFrameApply.apply\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 675\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mraw:\n\u001b[1;32m 676\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mapply_raw()\n\u001b[0;32m--> 678\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapply_standard\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py:798\u001b[0m, in \u001b[0;36mFrameApply.apply_standard\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 797\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mapply_standard\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[0;32m--> 798\u001b[0m results, res_index \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapply_series_generator\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 800\u001b[0m \u001b[38;5;66;03m# wrap results\u001b[39;00m\n\u001b[1;32m 801\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mwrap_results(results, res_index)\n", + "File \u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py:814\u001b[0m, in \u001b[0;36mFrameApply.apply_series_generator\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 811\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m option_context(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmode.chained_assignment\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[1;32m 812\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i, v \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(series_gen):\n\u001b[1;32m 813\u001b[0m \u001b[38;5;66;03m# ignore SettingWithCopy here in case the user mutates\u001b[39;00m\n\u001b[0;32m--> 814\u001b[0m results[i] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[43mv\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 815\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(results[i], ABCSeries):\n\u001b[1;32m 816\u001b[0m \u001b[38;5;66;03m# If we have a view on v, we need to make a copy because\u001b[39;00m\n\u001b[1;32m 817\u001b[0m \u001b[38;5;66;03m# series_generator will swap out the underlying data\u001b[39;00m\n\u001b[1;32m 818\u001b[0m results[i] \u001b[38;5;241m=\u001b[39m results[i]\u001b[38;5;241m.\u001b[39mcopy(deep\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n", + "Cell \u001b[0;32mIn[5], line 3\u001b[0m, in \u001b[0;36m\u001b[0;34m(row)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#challenge 1\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;66;03m#df_movies_bins['bin'] = df_movies['Votes'].apply(bins)\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m df_movies_bins[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbin\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m df_movies\u001b[38;5;241m.\u001b[39mapply(\u001b[38;5;28;01mlambda\u001b[39;00m row: \u001b[43mbins\u001b[49m(row[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mVotes\u001b[39m\u001b[38;5;124m'\u001b[39m]), axis\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m )\n\u001b[1;32m 4\u001b[0m df_movies_bins\u001b[38;5;241m.\u001b[39mhead()\n", + "\u001b[0;31mNameError\u001b[0m: name 'bins' is not defined" + ] + } + ], + "source": [ + "#challenge 1\n", + "#df_movies_bins['bin'] = df_movies['Votes'].apply(bins)\n", + "df_movies_bins['bin'] = df_movies.apply(lambda row: bins(row['Votes']), axis=1 )\n", + "df_movies_bins.head()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5470a6bb", + "metadata": {}, + "outputs": [], + "source": [ + "#chaganlle 2 \n", + "df_movies_revenue['revenue_per_minute'] = df_movies.apply(lambda row: row['Revenue (Millions)'] / row['Runtime (Minutes)']), axis=1 )\n", + "df_movies_revenue.head()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ba733f55", + "metadata": {}, + "outputs": [], + "source": [ + "#chaganlle 3" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5a96c42e", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "78bcf3f3", "metadata": {}, "outputs": [], "source": [] @@ -59,9 +318,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 +332,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.10.13" } }, "nbformat": 4, From 761eb9b0e5ac217f9ba3829c1c1795d54ea2dfc8 Mon Sep 17 00:00:00 2001 From: SilviaAlconGarrido Date: Sat, 28 Oct 2023 18:07:06 +0200 Subject: [PATCH 2/4] continue --- notebooks/your_code_here.ipynb | 641 ++++++++++++++++++++++++++++++--- 1 file changed, 597 insertions(+), 44 deletions(-) diff --git a/notebooks/your_code_here.ipynb b/notebooks/your_code_here.ipynb index 85d08af..7efb67b 100644 --- a/notebooks/your_code_here.ipynb +++ b/notebooks/your_code_here.ipynb @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 30, "id": "ace6da70", "metadata": {}, "outputs": [], @@ -22,7 +22,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 31, "id": "d3c3dd76", "metadata": {}, "outputs": [], @@ -32,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 32, "id": "f1c81c62", "metadata": {}, "outputs": [ @@ -181,7 +181,7 @@ "4 6.2 393727 325.02 40.0 " ] }, - "execution_count": 3, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -192,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 33, "id": "c53ce69f", "metadata": {}, "outputs": [ @@ -228,84 +228,635 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "id": "311cfa09", "metadata": {}, "outputs": [], "source": [ + "#challange 1\n", "def bins(votes):\n", - " if x >= 0 and x <= 999:\n", - " return'cat 1'\n", - " elif votes = 1000 >= 9999\n", - " print('cat 2')\n", - " elif votes = 10000 >= 99999\n", - " print('cat 3')\n", - " elif votes = 100000 >= 999999 \n", - " print('cat 4')\n", - " elif votes >= 1000000\n", - " print('cat 5')\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'\n", "\n" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 35, "id": "a6933b5d", "metadata": {}, "outputs": [ { - "ename": "NameError", - "evalue": "name 'bins' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[5], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#challenge 1\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;66;03m#df_movies_bins['bin'] = df_movies['Votes'].apply(bins)\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m df_movies_bins[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbin\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[43mdf_movies\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapply\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43;01mlambda\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mrow\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mbins\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrow\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mVotes\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 4\u001b[0m df_movies_bins\u001b[38;5;241m.\u001b[39mhead()\n", - "File \u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/frame.py:9423\u001b[0m, in \u001b[0;36mDataFrame.apply\u001b[0;34m(self, func, axis, raw, result_type, args, **kwargs)\u001b[0m\n\u001b[1;32m 9412\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpandas\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcore\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mapply\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m frame_apply\n\u001b[1;32m 9414\u001b[0m op \u001b[38;5;241m=\u001b[39m frame_apply(\n\u001b[1;32m 9415\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 9416\u001b[0m func\u001b[38;5;241m=\u001b[39mfunc,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 9421\u001b[0m kwargs\u001b[38;5;241m=\u001b[39mkwargs,\n\u001b[1;32m 9422\u001b[0m )\n\u001b[0;32m-> 9423\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mop\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapply\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39m__finalize__(\u001b[38;5;28mself\u001b[39m, method\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mapply\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", - "File \u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py:678\u001b[0m, in \u001b[0;36mFrameApply.apply\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 675\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mraw:\n\u001b[1;32m 676\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mapply_raw()\n\u001b[0;32m--> 678\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapply_standard\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py:798\u001b[0m, in \u001b[0;36mFrameApply.apply_standard\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 797\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mapply_standard\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[0;32m--> 798\u001b[0m results, res_index \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapply_series_generator\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 800\u001b[0m \u001b[38;5;66;03m# wrap results\u001b[39;00m\n\u001b[1;32m 801\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mwrap_results(results, res_index)\n", - "File \u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py:814\u001b[0m, in \u001b[0;36mFrameApply.apply_series_generator\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 811\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m option_context(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmode.chained_assignment\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[1;32m 812\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i, v \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(series_gen):\n\u001b[1;32m 813\u001b[0m \u001b[38;5;66;03m# ignore SettingWithCopy here in case the user mutates\u001b[39;00m\n\u001b[0;32m--> 814\u001b[0m results[i] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[43mv\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 815\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(results[i], ABCSeries):\n\u001b[1;32m 816\u001b[0m \u001b[38;5;66;03m# If we have a view on v, we need to make a copy because\u001b[39;00m\n\u001b[1;32m 817\u001b[0m \u001b[38;5;66;03m# series_generator will swap out the underlying data\u001b[39;00m\n\u001b[1;32m 818\u001b[0m results[i] \u001b[38;5;241m=\u001b[39m results[i]\u001b[38;5;241m.\u001b[39mcopy(deep\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n", - "Cell \u001b[0;32mIn[5], line 3\u001b[0m, in \u001b[0;36m\u001b[0;34m(row)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#challenge 1\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;66;03m#df_movies_bins['bin'] = df_movies['Votes'].apply(bins)\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m df_movies_bins[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbin\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m df_movies\u001b[38;5;241m.\u001b[39mapply(\u001b[38;5;28;01mlambda\u001b[39;00m row: \u001b[43mbins\u001b[49m(row[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mVotes\u001b[39m\u001b[38;5;124m'\u001b[39m]), axis\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m )\n\u001b[1;32m 4\u001b[0m df_movies_bins\u001b[38;5;241m.\u001b[39mhead()\n", - "\u001b[0;31mNameError\u001b[0m: name 'bins' is not defined" - ] + "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 3
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.0cat 3
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 3
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0None
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.0cat 3
\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 3 \n", + "1 7.0 485820 126.46 65.0 cat 3 \n", + "2 7.3 157606 138.12 62.0 cat 3 \n", + "3 7.2 60545 270.32 59.0 None \n", + "4 6.2 393727 325.02 40.0 cat 3 " + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "#challenge 1\n", + "#challange 1\n", "#df_movies_bins['bin'] = df_movies['Votes'].apply(bins)\n", - "df_movies_bins['bin'] = df_movies.apply(lambda row: bins(row['Votes']), axis=1 )\n", - "df_movies_bins.head()" + "df_movies['bin'] = df_movies.apply(lambda row: bins(row['Votes']), axis=1 )\n", + "df_movies.head()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "id": "5470a6bb", "metadata": {}, - "outputs": [], + "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_per_minute
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 32.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 31.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 31.180513
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0None2.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 32.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_per_minute \n", + "0 8.1 757074 333.13 76.0 cat 3 2.753140 \n", + "1 7.0 485820 126.46 65.0 cat 3 1.019839 \n", + "2 7.3 157606 138.12 62.0 cat 3 1.180513 \n", + "3 7.2 60545 270.32 59.0 None 2.502963 \n", + "4 6.2 393727 325.02 40.0 cat 3 2.642439 " + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "#chaganlle 2 \n", - "df_movies_revenue['revenue_per_minute'] = df_movies.apply(lambda row: row['Revenue (Millions)'] / row['Runtime (Minutes)']), axis=1 )\n", - "df_movies_revenue.head()" + "df_movies['revenue_per_minute'] = df_movies.apply(lambda row: row['Revenue (Millions)'] / row['Runtime (Minutes)'], axis=1 )\n", + "df_movies.head()" ] }, { "cell_type": "code", - "execution_count": null, - "id": "ba733f55", + "execution_count": 52, + "id": "8d1397a3", "metadata": {}, "outputs": [], "source": [ - "#chaganlle 3" + "#challange 3\n", + "def new_rating(x, y):\n", + " if 'Thriller' in x:\n", + " return y + 1 \n", + " elif 'Comedy' in x:\n", + " return y - 1\n", + " else:\n", + " return y" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "id": "ba733f55", + "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)Metascorebinrevenue_per_minutenew 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 32.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 31.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 31.1805138.3
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0None2.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 32.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_per_minute \\\n", + "0 8.1 757074 333.13 76.0 cat 3 2.753140 \n", + "1 7.0 485820 126.46 65.0 cat 3 1.019839 \n", + "2 7.3 157606 138.12 62.0 cat 3 1.180513 \n", + "3 7.2 60545 270.32 59.0 None 2.502963 \n", + "4 6.2 393727 325.02 40.0 cat 3 2.642439 \n", + "\n", + " new rating \n", + "0 8.1 \n", + "1 7.0 \n", + "2 8.3 \n", + "3 6.2 \n", + "4 6.2 " + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#chaganlle 3 We want to create a new rating where we add 1 point if the genre is thriller but subtract 1 point if the genre is comedy.\n", + "df_movies['new rating'] = df_movies.apply(lambda row: new_rating(row['Genre'], row['Rating']), axis=1 )\n", + "df_movies.head()" ] }, { "cell_type": "code", "execution_count": null, - "id": "5a96c42e", + "id": "ac9a19e4", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "#challange 4\n", + "def suma_title(tittle, votes):\n", + " x = ord(x)\n", + " \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "id": "039b12da", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "104\n" + ] + } + ], + "source": [ + "title = ord('h')\n", + "print(title)" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "5a96c42e", + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'Series' object has no attribute 'ord'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/var/folders/1m/9tdt_k994v175ff72qvvlr7r0000gn/T/ipykernel_80161/544787834.py\u001b[0m in \u001b[0;36m?\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m#challange 4\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdf_movies\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'prime numbers'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdf_movies\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mord\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Title'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Votes'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mdf_movies\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(self, func, axis, raw, result_type, args, **kwargs)\u001b[0m\n\u001b[1;32m 9419\u001b[0m \u001b[0mresult_type\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mresult_type\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9420\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9421\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9422\u001b[0m )\n\u001b[0;32m-> 9423\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mop\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__finalize__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"apply\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 674\u001b[0m \u001b[0;31m# raw\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 675\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mraw\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 676\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_raw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 677\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 678\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_standard\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 797\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mapply_standard\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 798\u001b[0;31m \u001b[0mresults\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mres_index\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_series_generator\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 799\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 800\u001b[0m \u001b[0;31m# wrap results\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 801\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrap_results\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresults\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mres_index\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 810\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 811\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0moption_context\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"mode.chained_assignment\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 812\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mseries_gen\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 813\u001b[0m \u001b[0;31m# ignore SettingWithCopy here in case the user mutates\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 814\u001b[0;31m \u001b[0mresults\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 815\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresults\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mABCSeries\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 816\u001b[0m \u001b[0;31m# If we have a view on v, we need to make a copy because\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 817\u001b[0m \u001b[0;31m# series_generator will swap out the underlying data\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/var/folders/1m/9tdt_k994v175ff72qvvlr7r0000gn/T/ipykernel_80161/544787834.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(row)\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdf_movies\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'prime numbers'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdf_movies\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mord\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Title'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Votes'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 5985\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mname\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_accessors\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5986\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_info_axis\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_can_hold_identifiers_and_holds_name\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5987\u001b[0m ):\n\u001b[1;32m 5988\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 5989\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mobject\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__getattribute__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m: 'Series' object has no attribute 'ord'" + ] + } + ], + "source": [ + "#challange 4\n", + "df_movies['prime numbers'] = df_movies.apply(lambda row: row['Title'] / row['Votes'], axis=1 )\n", + "df_movies.head()" + ] }, { "cell_type": "code", @@ -313,7 +864,9 @@ "id": "78bcf3f3", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "#ultimo ejercicio los caracteres a" + ] } ], "metadata": { From 2564c4e25216786335134bc22fb0289e50e6008d Mon Sep 17 00:00:00 2001 From: SilviaAlconGarrido Date: Sun, 29 Oct 2023 22:02:26 +0100 Subject: [PATCH 3/4] challenge5 --- notebooks/your_code_here.ipynb | 1111 ++++++++++++++++++++++++++++++-- 1 file changed, 1060 insertions(+), 51 deletions(-) diff --git a/notebooks/your_code_here.ipynb b/notebooks/your_code_here.ipynb index 7efb67b..84ac530 100644 --- a/notebooks/your_code_here.ipynb +++ b/notebooks/your_code_here.ipynb @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 81, "id": "ace6da70", "metadata": {}, "outputs": [], @@ -22,7 +22,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 82, "id": "d3c3dd76", "metadata": {}, "outputs": [], @@ -32,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 83, "id": "f1c81c62", "metadata": {}, "outputs": [ @@ -181,7 +181,7 @@ "4 6.2 393727 325.02 40.0 " ] }, - "execution_count": 32, + "execution_count": 83, "metadata": {}, "output_type": "execute_result" } @@ -192,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 84, "id": "c53ce69f", "metadata": {}, "outputs": [ @@ -228,7 +228,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 85, "id": "311cfa09", "metadata": {}, "outputs": [], @@ -250,7 +250,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 86, "id": "a6933b5d", "metadata": {}, "outputs": [ @@ -405,7 +405,7 @@ "4 6.2 393727 325.02 40.0 cat 3 " ] }, - "execution_count": 35, + "execution_count": 86, "metadata": {}, "output_type": "execute_result" } @@ -419,7 +419,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 87, "id": "5470a6bb", "metadata": {}, "outputs": [ @@ -580,7 +580,7 @@ "4 6.2 393727 325.02 40.0 cat 3 2.642439 " ] }, - "execution_count": 36, + "execution_count": 87, "metadata": {}, "output_type": "execute_result" } @@ -593,7 +593,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 88, "id": "8d1397a3", "metadata": {}, "outputs": [], @@ -610,7 +610,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 89, "id": "ba733f55", "metadata": {}, "outputs": [ @@ -784,7 +784,7 @@ "4 6.2 " ] }, - "execution_count": 53, + "execution_count": 89, "metadata": {}, "output_type": "execute_result" } @@ -797,76 +797,1085 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 90, "id": "ac9a19e4", "metadata": {}, "outputs": [], "source": [ - "#challange 4\n", - "def suma_title(tittle, votes):\n", - " x = ord(x)\n", - " \n", - " " + "#challange 4\n", + "def suma_title(x):\n", + " suma_asci = 0\n", + " for letter in x:\n", + " suma_asci += ord(letter)\n", + " return suma_asci\n", + "#suma_title('Guardians of the Galaxy')\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "id": "989c263f", + "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)Metascorebinrevenue_per_minutenew ratingDivided_Votes_Title
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 32.7531408.10.002866
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.0cat 31.0198397.00.002198
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 31.1805138.30.003325
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0None2.5029636.20.006623
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.0cat 32.6424396.20.003180
\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_per_minute \\\n", + "0 8.1 757074 333.13 76.0 cat 3 2.753140 \n", + "1 7.0 485820 126.46 65.0 cat 3 1.019839 \n", + "2 7.3 157606 138.12 62.0 cat 3 1.180513 \n", + "3 7.2 60545 270.32 59.0 None 2.502963 \n", + "4 6.2 393727 325.02 40.0 cat 3 2.642439 \n", + "\n", + " new rating Divided_Votes_Title \n", + "0 8.1 0.002866 \n", + "1 7.0 0.002198 \n", + "2 8.3 0.003325 \n", + "3 6.2 0.006623 \n", + "4 6.2 0.003180 " + ] + }, + "execution_count": 91, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#challange 4\n", + "df_movies['Divided_Votes_Title'] = df_movies.apply(lambda row: suma_title(row['Title']) / row['Votes'], axis=1 )\n", + "df_movies.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "id": "039b12da", + "metadata": {}, + "outputs": [], + "source": [ + "#challange 4\n", + "def prime(n):\n", + " n = int(n)\n", + " for i in range(2,n):\n", + " if (n%i) == 0:\n", + " return False\n", + " \n", + " return True\n", + "#prime(7) " + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "id": "5a96c42e", + "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", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)Metascorebinrevenue_per_minutenew ratingDivided_Votes_TitlePrime_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.0cat 32.7531408.10.002866True
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.0cat 31.0198397.00.002198True
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 31.1805138.30.003325True
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0None2.5029636.20.006623True
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.0cat 32.6424396.20.003180True
\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_per_minute \\\n", + "0 8.1 757074 333.13 76.0 cat 3 2.753140 \n", + "1 7.0 485820 126.46 65.0 cat 3 1.019839 \n", + "2 7.3 157606 138.12 62.0 cat 3 1.180513 \n", + "3 7.2 60545 270.32 59.0 None 2.502963 \n", + "4 6.2 393727 325.02 40.0 cat 3 2.642439 \n", + "\n", + " new rating Divided_Votes_Title Prime_number \n", + "0 8.1 0.002866 True \n", + "1 7.0 0.002198 True \n", + "2 8.3 0.003325 True \n", + "3 6.2 0.006623 True \n", + "4 6.2 0.003180 True " + ] + }, + "execution_count": 93, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#challange 4\n", + "df_movies['Prime_number'] = df_movies.apply(lambda row: prime(row['Divided_Votes_Title']), axis=1 )\n", + "df_movies.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 155, + "id": "f9c77ab1", + "metadata": {}, + "outputs": [], + "source": [ + "#numero de votos mas Metascore en comparacion de lo ganado y lo ganado por minuto\n", + "def compare(x, y, z, i):\n", + " if x >= y:\n", + " return z + i \n", + " elif x <= y:\n", + " return z - i\n", + " else:\n", + " return z\n" + ] + }, + { + "cell_type": "code", + "execution_count": 159, + "id": "969474cf", + "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", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)Metascorebinrevenue_per_minutenew ratingDivided_Votes_TitlePrime_numbervotes_revenuevotes_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.0cat 32.7531408.10.002866True756998.0756998.0
12PrometheusAdventure,Mystery,Sci-FiFollowing clues to the origin of mankind, a te...Ridley ScottNoomi Rapace, Logan Marshall-Green, Michael Fa...20121247.0485820126.4665.0cat 31.0198397.00.002198True485755.0485755.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 31.1805138.30.003325True157544.0157544.0
34SingAnimation,Comedy,FamilyIn a city of humanoid animals, a hustling thea...Christophe LourdeletMatthew McConaughey,Reese Witherspoon, Seth Ma...20161087.260545270.3259.0None2.5029636.20.006623True60486.060486.0
45Suicide SquadAction,Adventure,FantasyA secret government agency recruits some of th...David AyerWill Smith, Jared Leto, Margot Robbie, Viola D...20161236.2393727325.0240.0cat 32.6424396.20.003180True393687.0393687.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 bin revenue_per_minute \\\n", + "0 8.1 757074 333.13 76.0 cat 3 2.753140 \n", + "1 7.0 485820 126.46 65.0 cat 3 1.019839 \n", + "2 7.3 157606 138.12 62.0 cat 3 1.180513 \n", + "3 7.2 60545 270.32 59.0 None 2.502963 \n", + "4 6.2 393727 325.02 40.0 cat 3 2.642439 \n", + "\n", + " new rating Divided_Votes_Title Prime_number votes_revenue \\\n", + "0 8.1 0.002866 True 756998.0 \n", + "1 7.0 0.002198 True 485755.0 \n", + "2 8.3 0.003325 True 157544.0 \n", + "3 6.2 0.006623 True 60486.0 \n", + "4 6.2 0.003180 True 393687.0 \n", + "\n", + " votes_metascore \n", + "0 756998.0 \n", + "1 485755.0 \n", + "2 157544.0 \n", + "3 60486.0 \n", + "4 393687.0 " + ] + }, + "execution_count": 159, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_movies['votes_metascore'] = df_movies.apply(lambda row: compare(row['revenue_per_minute'], row['Revenue (Millions)'], row['Votes'], row['Metascore']), axis=1 )\n", + "df_movies.head()" ] }, { "cell_type": "code", - "execution_count": 61, - "id": "039b12da", + "execution_count": 160, + "id": "f37e7225", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "104\n" - ] + "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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
RankTitleGenreDescriptionDirectorActorsYearRuntime (Minutes)RatingVotesRevenue (Millions)Metascorebinrevenue_per_minutenew ratingDivided_Votes_TitlePrime_numbervotes_revenuevotes_metascore
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 33.5086849.00.000754True1791834.01791834.0
8081InceptionAction,Adventure,Sci-FiA thief, who steals corporate secrets through ...Christopher NolanLeonardo DiCaprio, Joseph Gordon-Levitt, Ellen...20101488.81583625292.5774.0cat 31.9768248.80.000592True1583551.01583551.0
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 32.7325009.50.001556True1222567.01222567.0
3637InterstellarAdventure,Drama,Sci-FiA team of explorers travel through a wormhole ...Christopher NolanMatthew McConaughey, Anne Hathaway, Jessica Ch...20141698.61047747187.9974.0cat 31.1123678.60.001215True1047673.01047673.0
7677The AvengersAction,Sci-FiEarth's mightiest heroes must come together an...Joss WhedonRobert Downey Jr., Chris Evans, Scarlett Johan...20121438.11045588623.2869.0cat 34.3586018.10.001098True1045519.01045519.0
............................................................
967968The WalkAdventure,Biography,CrimeIn 1974, high-wire artist Philippe Petit recru...Robert ZemeckisJoseph Gordon-Levitt, Charlotte Le Bon,Guillau...20151237.39237810.14NaNNone0.0824397.30.007794TrueNaNNaN
969970The Lone RangerAction,Adventure,WesternNative American warrior Tonto recounts the unt...Gore VerbinskiJohnny Depp, Armie Hammer, William Fichtner,To...20131506.519085589.29NaNcat 30.5952676.50.007115TrueNaNNaN
971972DisturbiaDrama,Mystery,ThrillerA teen living under house arrest becomes convi...D.J. CarusoShia LaBeouf, David Morse, Carrie-Anne Moss, S...20071056.919349180.05NaNcat 30.7623817.90.004832TrueNaNNaN
989990SelmaBiography,Drama,HistoryA chronicle of Martin Luther King's campaign t...Ava DuVernayDavid Oyelowo, Carmen Ejogo, Tim Roth, Lorrain...20141287.56763752.07NaNNone0.4067977.50.007363TrueNaNNaN
992993Take Me Home TonightComedy,Drama,RomanceFour years after graduation, an awkward high s...Michael DowseTopher Grace, Anna Faris, Dan Fogler, Teresa P...2011976.3454196.92NaNNone0.0713405.30.039389TrueNaNNaN
\n", + "

1000 rows × 19 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", + "967 968 The Walk Adventure,Biography,Crime \n", + "969 970 The Lone Ranger Action,Adventure,Western \n", + "971 972 Disturbia Drama,Mystery,Thriller \n", + "989 990 Selma Biography,Drama,History \n", + "992 993 Take Me Home Tonight Comedy,Drama,Romance \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", + "967 In 1974, high-wire artist Philippe Petit recru... Robert Zemeckis \n", + "969 Native American warrior Tonto recounts the unt... Gore Verbinski \n", + "971 A teen living under house arrest becomes convi... D.J. Caruso \n", + "989 A chronicle of Martin Luther King's campaign t... Ava DuVernay \n", + "992 Four years after graduation, an awkward high s... Michael Dowse \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", + "967 Joseph Gordon-Levitt, Charlotte Le Bon,Guillau... 2015 \n", + "969 Johnny Depp, Armie Hammer, William Fichtner,To... 2013 \n", + "971 Shia LaBeouf, David Morse, Carrie-Anne Moss, S... 2007 \n", + "989 David Oyelowo, Carmen Ejogo, Tim Roth, Lorrain... 2014 \n", + "992 Topher Grace, Anna Faris, Dan Fogler, Teresa P... 2011 \n", + "\n", + " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore bin \\\n", + "54 152 9.0 1791916 533.32 82.0 cat 3 \n", + "80 148 8.8 1583625 292.57 74.0 cat 3 \n", + "124 164 8.5 1222645 448.13 78.0 cat 3 \n", + "36 169 8.6 1047747 187.99 74.0 cat 3 \n", + "76 143 8.1 1045588 623.28 69.0 cat 3 \n", + ".. ... ... ... ... ... ... \n", + "967 123 7.3 92378 10.14 NaN None \n", + "969 150 6.5 190855 89.29 NaN cat 3 \n", + "971 105 6.9 193491 80.05 NaN cat 3 \n", + "989 128 7.5 67637 52.07 NaN None \n", + "992 97 6.3 45419 6.92 NaN None \n", + "\n", + " revenue_per_minute new rating Divided_Votes_Title Prime_number \\\n", + "54 3.508684 9.0 0.000754 True \n", + "80 1.976824 8.8 0.000592 True \n", + "124 2.732500 9.5 0.001556 True \n", + "36 1.112367 8.6 0.001215 True \n", + "76 4.358601 8.1 0.001098 True \n", + ".. ... ... ... ... \n", + "967 0.082439 7.3 0.007794 True \n", + "969 0.595267 6.5 0.007115 True \n", + "971 0.762381 7.9 0.004832 True \n", + "989 0.406797 7.5 0.007363 True \n", + "992 0.071340 5.3 0.039389 True \n", + "\n", + " votes_revenue votes_metascore \n", + "54 1791834.0 1791834.0 \n", + "80 1583551.0 1583551.0 \n", + "124 1222567.0 1222567.0 \n", + "36 1047673.0 1047673.0 \n", + "76 1045519.0 1045519.0 \n", + ".. ... ... \n", + "967 NaN NaN \n", + "969 NaN NaN \n", + "971 NaN NaN \n", + "989 NaN NaN \n", + "992 NaN NaN \n", + "\n", + "[1000 rows x 19 columns]" + ] + }, + "execution_count": 160, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "title = ord('h')\n", - "print(title)" + "df_movies.sort_values(by= ['votes_metascore'], ascending= False)" ] }, { "cell_type": "code", - "execution_count": 54, - "id": "5a96c42e", + "execution_count": 164, + "id": "78bcf3f3", "metadata": {}, "outputs": [ { - "ename": "AttributeError", - "evalue": "'Series' object has no attribute 'ord'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/var/folders/1m/9tdt_k994v175ff72qvvlr7r0000gn/T/ipykernel_80161/544787834.py\u001b[0m in \u001b[0;36m?\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m#challange 4\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdf_movies\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'prime numbers'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdf_movies\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mord\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Title'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Votes'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mdf_movies\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(self, func, axis, raw, result_type, args, **kwargs)\u001b[0m\n\u001b[1;32m 9419\u001b[0m \u001b[0mresult_type\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mresult_type\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9420\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9421\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9422\u001b[0m )\n\u001b[0;32m-> 9423\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mop\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__finalize__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"apply\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 674\u001b[0m \u001b[0;31m# raw\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 675\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mraw\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 676\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_raw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 677\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 678\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_standard\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 797\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mapply_standard\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 798\u001b[0;31m \u001b[0mresults\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mres_index\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_series_generator\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 799\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 800\u001b[0m \u001b[0;31m# wrap results\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 801\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrap_results\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresults\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mres_index\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 810\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 811\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0moption_context\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"mode.chained_assignment\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 812\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mseries_gen\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 813\u001b[0m \u001b[0;31m# ignore SettingWithCopy here in case the user mutates\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 814\u001b[0;31m \u001b[0mresults\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 815\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresults\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mABCSeries\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 816\u001b[0m \u001b[0;31m# If we have a view on v, we need to make a copy because\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 817\u001b[0m \u001b[0;31m# series_generator will swap out the underlying data\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/var/folders/1m/9tdt_k994v175ff72qvvlr7r0000gn/T/ipykernel_80161/544787834.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(row)\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdf_movies\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'prime numbers'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdf_movies\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mord\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Title'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Votes'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/miniconda3/envs/m1_env/lib/python3.10/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36m?\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 5985\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mname\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_accessors\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5986\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_info_axis\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_can_hold_identifiers_and_holds_name\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5987\u001b[0m ):\n\u001b[1;32m 5988\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 5989\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mobject\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__getattribute__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mAttributeError\u001b[0m: 'Series' object has no attribute 'ord'" + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 1000 entries, 0 to 999\n", + "Series name: Title\n", + "Non-Null Count Dtype \n", + "-------------- ----- \n", + "1000 non-null object\n", + "dtypes: object(1)\n", + "memory usage: 7.9+ KB\n" ] } ], "source": [ - "#challange 4\n", - "df_movies['prime numbers'] = df_movies.apply(lambda row: row['Title'] / row['Votes'], axis=1 )\n", - "df_movies.head()" + "#Bonus: ultimo ejercicio se puede sacar sin regex\n", + "df_movies['Title'].info()" ] }, { "cell_type": "code", "execution_count": null, - "id": "78bcf3f3", + "id": "e26cfb9c", "metadata": {}, "outputs": [], - "source": [ - "#ultimo ejercicio los caracteres a" - ] + "source": [] } ], "metadata": { From 89a3f1d217612a267d38428bde0b32f5eb38726e Mon Sep 17 00:00:00 2001 From: SilviaAlconGarrido Date: Mon, 30 Oct 2023 18:33:17 +0100 Subject: [PATCH 4/4] finish-5 --- notebooks/your_code_here.ipynb | 264 ++++++++++++++++++++++----------- 1 file changed, 175 insertions(+), 89 deletions(-) diff --git a/notebooks/your_code_here.ipynb b/notebooks/your_code_here.ipynb index 84ac530..4d0acd5 100644 --- a/notebooks/your_code_here.ipynb +++ b/notebooks/your_code_here.ipynb @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 81, + "execution_count": 1, "id": "ace6da70", "metadata": {}, "outputs": [], @@ -22,7 +22,7 @@ }, { "cell_type": "code", - "execution_count": 82, + "execution_count": 2, "id": "d3c3dd76", "metadata": {}, "outputs": [], @@ -32,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 83, + "execution_count": 3, "id": "f1c81c62", "metadata": {}, "outputs": [ @@ -181,7 +181,7 @@ "4 6.2 393727 325.02 40.0 " ] }, - "execution_count": 83, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -192,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 84, + "execution_count": 4, "id": "c53ce69f", "metadata": {}, "outputs": [ @@ -228,7 +228,7 @@ }, { "cell_type": "code", - "execution_count": 85, + "execution_count": 5, "id": "311cfa09", "metadata": {}, "outputs": [], @@ -250,7 +250,7 @@ }, { "cell_type": "code", - "execution_count": 86, + "execution_count": 6, "id": "a6933b5d", "metadata": {}, "outputs": [ @@ -405,7 +405,7 @@ "4 6.2 393727 325.02 40.0 cat 3 " ] }, - "execution_count": 86, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -419,7 +419,7 @@ }, { "cell_type": "code", - "execution_count": 87, + "execution_count": 7, "id": "5470a6bb", "metadata": {}, "outputs": [ @@ -580,7 +580,7 @@ "4 6.2 393727 325.02 40.0 cat 3 2.642439 " ] }, - "execution_count": 87, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -593,7 +593,7 @@ }, { "cell_type": "code", - "execution_count": 88, + "execution_count": 8, "id": "8d1397a3", "metadata": {}, "outputs": [], @@ -610,7 +610,7 @@ }, { "cell_type": "code", - "execution_count": 89, + "execution_count": 9, "id": "ba733f55", "metadata": {}, "outputs": [ @@ -784,7 +784,7 @@ "4 6.2 " ] }, - "execution_count": 89, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -797,10 +797,21 @@ }, { "cell_type": "code", - "execution_count": 90, + "execution_count": 21, "id": "ac9a19e4", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "2170" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "#challange 4\n", "def suma_title(x):\n", @@ -814,7 +825,7 @@ }, { "cell_type": "code", - "execution_count": 91, + "execution_count": 11, "id": "989c263f", "metadata": {}, "outputs": [ @@ -994,7 +1005,7 @@ "4 6.2 0.003180 " ] }, - "execution_count": 91, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -1007,7 +1018,7 @@ }, { "cell_type": "code", - "execution_count": 92, + "execution_count": 22, "id": "039b12da", "metadata": {}, "outputs": [], @@ -1015,17 +1026,22 @@ "#challange 4\n", "def prime(n):\n", " n = int(n)\n", - " for i in range(2,n):\n", - " if (n%i) == 0:\n", - " return False\n", - " \n", - " return True\n", + " if n <= 1:\n", + " return False\n", + " elif n == 2:\n", + " return True\n", + " else:\n", + " for i in range(2,n):\n", + " if (n%i) == 0:\n", + " return False\n", + "\n", + " return True\n", "#prime(7) " ] }, { "cell_type": "code", - "execution_count": 93, + "execution_count": 23, "id": "5a96c42e", "metadata": {}, "outputs": [ @@ -1067,6 +1083,7 @@ " new rating\n", " Divided_Votes_Title\n", " Prime_number\n", + " votes_metascore\n", " \n", " \n", " \n", @@ -1088,7 +1105,8 @@ " 2.753140\n", " 8.1\n", " 0.002866\n", - " True\n", + " False\n", + " 756998.0\n", " \n", " \n", " 1\n", @@ -1108,7 +1126,8 @@ " 1.019839\n", " 7.0\n", " 0.002198\n", - " True\n", + " False\n", + " 485755.0\n", " \n", " \n", " 2\n", @@ -1128,7 +1147,8 @@ " 1.180513\n", " 8.3\n", " 0.003325\n", - " True\n", + " False\n", + " 157544.0\n", " \n", " \n", " 3\n", @@ -1148,7 +1168,8 @@ " 2.502963\n", " 6.2\n", " 0.006623\n", - " True\n", + " False\n", + " 60486.0\n", " \n", " \n", " 4\n", @@ -1168,7 +1189,8 @@ " 2.642439\n", " 6.2\n", " 0.003180\n", - " True\n", + " False\n", + " 393687.0\n", " \n", " \n", "\n", @@ -1203,15 +1225,15 @@ "3 7.2 60545 270.32 59.0 None 2.502963 \n", "4 6.2 393727 325.02 40.0 cat 3 2.642439 \n", "\n", - " new rating Divided_Votes_Title Prime_number \n", - "0 8.1 0.002866 True \n", - "1 7.0 0.002198 True \n", - "2 8.3 0.003325 True \n", - "3 6.2 0.006623 True \n", - "4 6.2 0.003180 True " + " new rating Divided_Votes_Title Prime_number votes_metascore \n", + "0 8.1 0.002866 False 756998.0 \n", + "1 7.0 0.002198 False 485755.0 \n", + "2 8.3 0.003325 False 157544.0 \n", + "3 6.2 0.006623 False 60486.0 \n", + "4 6.2 0.003180 False 393687.0 " ] }, - "execution_count": 93, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -1224,7 +1246,28 @@ }, { "cell_type": "code", - "execution_count": 155, + "execution_count": 27, + "id": "2d26096b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Prime_number\n", + "False 981\n", + "True 19\n", + "Name: count, dtype: int64\n" + ] + } + ], + "source": [ + "print(df_movies['Prime_number'].value_counts())" + ] + }, + { + "cell_type": "code", + "execution_count": 14, "id": "f9c77ab1", "metadata": {}, "outputs": [], @@ -1241,7 +1284,7 @@ }, { "cell_type": "code", - "execution_count": 159, + "execution_count": 15, "id": "969474cf", "metadata": {}, "outputs": [ @@ -1283,7 +1326,6 @@ " new rating\n", " Divided_Votes_Title\n", " Prime_number\n", - " votes_revenue\n", " votes_metascore\n", " \n", " \n", @@ -1308,7 +1350,6 @@ " 0.002866\n", " True\n", " 756998.0\n", - " 756998.0\n", " \n", " \n", " 1\n", @@ -1330,7 +1371,6 @@ " 0.002198\n", " True\n", " 485755.0\n", - " 485755.0\n", " \n", " \n", " 2\n", @@ -1352,7 +1392,6 @@ " 0.003325\n", " True\n", " 157544.0\n", - " 157544.0\n", " \n", " \n", " 3\n", @@ -1374,7 +1413,6 @@ " 0.006623\n", " True\n", " 60486.0\n", - " 60486.0\n", " \n", " \n", " 4\n", @@ -1396,7 +1434,6 @@ " 0.003180\n", " True\n", " 393687.0\n", - " 393687.0\n", " \n", " \n", "\n", @@ -1431,22 +1468,15 @@ "3 7.2 60545 270.32 59.0 None 2.502963 \n", "4 6.2 393727 325.02 40.0 cat 3 2.642439 \n", "\n", - " new rating Divided_Votes_Title Prime_number votes_revenue \\\n", - "0 8.1 0.002866 True 756998.0 \n", - "1 7.0 0.002198 True 485755.0 \n", - "2 8.3 0.003325 True 157544.0 \n", - "3 6.2 0.006623 True 60486.0 \n", - "4 6.2 0.003180 True 393687.0 \n", - "\n", - " votes_metascore \n", - "0 756998.0 \n", - "1 485755.0 \n", - "2 157544.0 \n", - "3 60486.0 \n", - "4 393687.0 " + " new rating Divided_Votes_Title Prime_number votes_metascore \n", + "0 8.1 0.002866 True 756998.0 \n", + "1 7.0 0.002198 True 485755.0 \n", + "2 8.3 0.003325 True 157544.0 \n", + "3 6.2 0.006623 True 60486.0 \n", + "4 6.2 0.003180 True 393687.0 " ] }, - "execution_count": 159, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -1458,7 +1488,7 @@ }, { "cell_type": "code", - "execution_count": 160, + "execution_count": 16, "id": "f37e7225", "metadata": {}, "outputs": [ @@ -1500,7 +1530,6 @@ " new rating\n", " Divided_Votes_Title\n", " Prime_number\n", - " votes_revenue\n", " votes_metascore\n", " \n", " \n", @@ -1525,7 +1554,6 @@ " 0.000754\n", " True\n", " 1791834.0\n", - " 1791834.0\n", " \n", " \n", " 80\n", @@ -1547,7 +1575,6 @@ " 0.000592\n", " True\n", " 1583551.0\n", - " 1583551.0\n", " \n", " \n", " 124\n", @@ -1569,7 +1596,6 @@ " 0.001556\n", " True\n", " 1222567.0\n", - " 1222567.0\n", " \n", " \n", " 36\n", @@ -1591,7 +1617,6 @@ " 0.001215\n", " True\n", " 1047673.0\n", - " 1047673.0\n", " \n", " \n", " 76\n", @@ -1613,7 +1638,6 @@ " 0.001098\n", " True\n", " 1045519.0\n", - " 1045519.0\n", " \n", " \n", " ...\n", @@ -1635,7 +1659,6 @@ " ...\n", " ...\n", " ...\n", - " ...\n", " \n", " \n", " 967\n", @@ -1657,7 +1680,6 @@ " 0.007794\n", " True\n", " NaN\n", - " NaN\n", " \n", " \n", " 969\n", @@ -1679,7 +1701,6 @@ " 0.007115\n", " True\n", " NaN\n", - " NaN\n", " \n", " \n", " 971\n", @@ -1701,7 +1722,6 @@ " 0.004832\n", " True\n", " NaN\n", - " NaN\n", " \n", " \n", " 989\n", @@ -1723,7 +1743,6 @@ " 0.007363\n", " True\n", " NaN\n", - " NaN\n", " \n", " \n", " 992\n", @@ -1745,11 +1764,10 @@ " 0.039389\n", " True\n", " NaN\n", - " NaN\n", " \n", " \n", "\n", - "

1000 rows × 19 columns

\n", + "

1000 rows × 18 columns

\n", "" ], "text/plain": [ @@ -1818,23 +1836,23 @@ "989 0.406797 7.5 0.007363 True \n", "992 0.071340 5.3 0.039389 True \n", "\n", - " votes_revenue votes_metascore \n", - "54 1791834.0 1791834.0 \n", - "80 1583551.0 1583551.0 \n", - "124 1222567.0 1222567.0 \n", - "36 1047673.0 1047673.0 \n", - "76 1045519.0 1045519.0 \n", - ".. ... ... \n", - "967 NaN NaN \n", - "969 NaN NaN \n", - "971 NaN NaN \n", - "989 NaN NaN \n", - "992 NaN NaN \n", + " votes_metascore \n", + "54 1791834.0 \n", + "80 1583551.0 \n", + "124 1222567.0 \n", + "36 1047673.0 \n", + "76 1045519.0 \n", + ".. ... \n", + "967 NaN \n", + "969 NaN \n", + "971 NaN \n", + "989 NaN \n", + "992 NaN \n", "\n", - "[1000 rows x 19 columns]" + "[1000 rows x 18 columns]" ] }, - "execution_count": 160, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -1845,7 +1863,71 @@ }, { "cell_type": "code", - "execution_count": 164, + "execution_count": 20, + "id": "b0120663", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0 0.002866\n", + "1 0.002198\n", + "2 0.003325\n", + "3 0.006623\n", + "4 0.003180\n", + " ... \n", + "995 0.066667\n", + "996 0.017744\n", + "997 0.026592\n", + "998 0.237246\n", + "999 0.075674\n", + "Name: Divided_Votes_Title, Length: 1000, dtype: float64" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_movies['Divided_Votes_Title']" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "e26cfb9c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0 True\n", + "1 True\n", + "2 True\n", + "3 True\n", + "4 True\n", + " ... \n", + "995 True\n", + "996 True\n", + "997 True\n", + "998 True\n", + "999 True\n", + "Name: Prime_number, Length: 1000, dtype: bool" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_movies['Prime_number']" + ] + }, + { + "cell_type": "code", + "execution_count": 17, "id": "78bcf3f3", "metadata": {}, "outputs": [ @@ -1872,10 +1954,14 @@ { "cell_type": "code", "execution_count": null, - "id": "e26cfb9c", + "id": "3b5a7da1", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "1. encontrar una funcion que te traduzca la descripcion a hash SHA256(esta en internet)\n", + "2.haccer una bucle for por el SHA256 y si el valor es un numero te lo vaya sumando.\n", + "3. Haces un if para comprobar si ese numero asta entre el revenue y el numero de votor. DEvuelve True/False" + ] } ], "metadata": {