{"cells":[{"cell_type":"code","execution_count":1,"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","execution":{"iopub.execute_input":"2021-06-21T12:32:55.394360Z","iopub.status.busy":"2021-06-21T12:32:55.393741Z","iopub.status.idle":"2021-06-21T12:32:55.415999Z","shell.execute_reply":"2021-06-21T12:32:55.414664Z","shell.execute_reply.started":"2021-06-21T12:32:55.394257Z"},"trusted":true},"outputs":[],"source":["# This Python 3 environment comes with many helpful analytics libraries installed\n","# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n","# For example, here's several helpful packages to load\n","\n","import numpy as np # linear algebra\n","import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n","\n","# Input data files are available in the read-only \"../input/\" directory\n","# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n","\n","import os\n","for dirname, _, filenames in os.walk('/kaggle/input'):\n"," for filename in filenames:\n"," print(os.path.join(dirname, filename))\n","\n","# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n","# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session"]},{"cell_type":"code","execution_count":2,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:36:31.348105Z","iopub.status.busy":"2021-06-21T12:36:31.347717Z","iopub.status.idle":"2021-06-21T12:36:32.003856Z","shell.execute_reply":"2021-06-21T12:36:32.002744Z","shell.execute_reply.started":"2021-06-21T12:36:31.348073Z"},"trusted":true},"outputs":[{"ename":"FileNotFoundError","evalue":"[Errno 2] No such file or directory: '/kaggle/input/tmdb-movie-metadata/tmdb_5000_movies.csv'","output_type":"error","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)","Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m movies \u001b[39m=\u001b[39m pd\u001b[39m.\u001b[39;49mread_csv(\u001b[39m'\u001b[39;49m\u001b[39m/kaggle/input/tmdb-movie-metadata/tmdb_5000_movies.csv\u001b[39;49m\u001b[39m'\u001b[39;49m)\n\u001b[1;32m 2\u001b[0m credits \u001b[39m=\u001b[39m pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39m/kaggle/input/tmdb-movie-metadata/tmdb_5000_credits.csv\u001b[39m\u001b[39m'\u001b[39m) \n","File \u001b[0;32m~/.local/lib/python3.10/site-packages/pandas/io/parsers/readers.py:912\u001b[0m, in \u001b[0;36mread_csv\u001b[0;34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)\u001b[0m\n\u001b[1;32m 899\u001b[0m kwds_defaults \u001b[39m=\u001b[39m _refine_defaults_read(\n\u001b[1;32m 900\u001b[0m dialect,\n\u001b[1;32m 901\u001b[0m delimiter,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 908\u001b[0m dtype_backend\u001b[39m=\u001b[39mdtype_backend,\n\u001b[1;32m 909\u001b[0m )\n\u001b[1;32m 910\u001b[0m kwds\u001b[39m.\u001b[39mupdate(kwds_defaults)\n\u001b[0;32m--> 912\u001b[0m \u001b[39mreturn\u001b[39;00m _read(filepath_or_buffer, kwds)\n","File \u001b[0;32m~/.local/lib/python3.10/site-packages/pandas/io/parsers/readers.py:577\u001b[0m, in \u001b[0;36m_read\u001b[0;34m(filepath_or_buffer, kwds)\u001b[0m\n\u001b[1;32m 574\u001b[0m _validate_names(kwds\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39mnames\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39mNone\u001b[39;00m))\n\u001b[1;32m 576\u001b[0m \u001b[39m# Create the parser.\u001b[39;00m\n\u001b[0;32m--> 577\u001b[0m parser \u001b[39m=\u001b[39m TextFileReader(filepath_or_buffer, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwds)\n\u001b[1;32m 579\u001b[0m \u001b[39mif\u001b[39;00m chunksize \u001b[39mor\u001b[39;00m iterator:\n\u001b[1;32m 580\u001b[0m \u001b[39mreturn\u001b[39;00m parser\n","File \u001b[0;32m~/.local/lib/python3.10/site-packages/pandas/io/parsers/readers.py:1407\u001b[0m, in \u001b[0;36mTextFileReader.__init__\u001b[0;34m(self, f, engine, **kwds)\u001b[0m\n\u001b[1;32m 1404\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39moptions[\u001b[39m\"\u001b[39m\u001b[39mhas_index_names\u001b[39m\u001b[39m\"\u001b[39m] \u001b[39m=\u001b[39m kwds[\u001b[39m\"\u001b[39m\u001b[39mhas_index_names\u001b[39m\u001b[39m\"\u001b[39m]\n\u001b[1;32m 1406\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mhandles: IOHandles \u001b[39m|\u001b[39m \u001b[39mNone\u001b[39;00m \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[0;32m-> 1407\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_engine \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_make_engine(f, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mengine)\n","File \u001b[0;32m~/.local/lib/python3.10/site-packages/pandas/io/parsers/readers.py:1661\u001b[0m, in \u001b[0;36mTextFileReader._make_engine\u001b[0;34m(self, f, engine)\u001b[0m\n\u001b[1;32m 1659\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39m\"\u001b[39m\u001b[39mb\u001b[39m\u001b[39m\"\u001b[39m \u001b[39mnot\u001b[39;00m \u001b[39min\u001b[39;00m mode:\n\u001b[1;32m 1660\u001b[0m mode \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mb\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m-> 1661\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mhandles \u001b[39m=\u001b[39m get_handle(\n\u001b[1;32m 1662\u001b[0m f,\n\u001b[1;32m 1663\u001b[0m mode,\n\u001b[1;32m 1664\u001b[0m encoding\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49moptions\u001b[39m.\u001b[39;49mget(\u001b[39m\"\u001b[39;49m\u001b[39mencoding\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39mNone\u001b[39;49;00m),\n\u001b[1;32m 1665\u001b[0m compression\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49moptions\u001b[39m.\u001b[39;49mget(\u001b[39m\"\u001b[39;49m\u001b[39mcompression\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39mNone\u001b[39;49;00m),\n\u001b[1;32m 1666\u001b[0m memory_map\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49moptions\u001b[39m.\u001b[39;49mget(\u001b[39m\"\u001b[39;49m\u001b[39mmemory_map\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39mFalse\u001b[39;49;00m),\n\u001b[1;32m 1667\u001b[0m is_text\u001b[39m=\u001b[39;49mis_text,\n\u001b[1;32m 1668\u001b[0m errors\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49moptions\u001b[39m.\u001b[39;49mget(\u001b[39m\"\u001b[39;49m\u001b[39mencoding_errors\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39m\"\u001b[39;49m\u001b[39mstrict\u001b[39;49m\u001b[39m\"\u001b[39;49m),\n\u001b[1;32m 1669\u001b[0m storage_options\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49moptions\u001b[39m.\u001b[39;49mget(\u001b[39m\"\u001b[39;49m\u001b[39mstorage_options\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39mNone\u001b[39;49;00m),\n\u001b[1;32m 1670\u001b[0m )\n\u001b[1;32m 1671\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mhandles \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m 1672\u001b[0m f \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mhandles\u001b[39m.\u001b[39mhandle\n","File \u001b[0;32m~/.local/lib/python3.10/site-packages/pandas/io/common.py:859\u001b[0m, in \u001b[0;36mget_handle\u001b[0;34m(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)\u001b[0m\n\u001b[1;32m 854\u001b[0m \u001b[39melif\u001b[39;00m \u001b[39misinstance\u001b[39m(handle, \u001b[39mstr\u001b[39m):\n\u001b[1;32m 855\u001b[0m \u001b[39m# Check whether the filename is to be opened in binary mode.\u001b[39;00m\n\u001b[1;32m 856\u001b[0m \u001b[39m# Binary mode does not support 'encoding' and 'newline'.\u001b[39;00m\n\u001b[1;32m 857\u001b[0m \u001b[39mif\u001b[39;00m ioargs\u001b[39m.\u001b[39mencoding \u001b[39mand\u001b[39;00m \u001b[39m\"\u001b[39m\u001b[39mb\u001b[39m\u001b[39m\"\u001b[39m \u001b[39mnot\u001b[39;00m \u001b[39min\u001b[39;00m ioargs\u001b[39m.\u001b[39mmode:\n\u001b[1;32m 858\u001b[0m \u001b[39m# Encoding\u001b[39;00m\n\u001b[0;32m--> 859\u001b[0m handle \u001b[39m=\u001b[39m \u001b[39mopen\u001b[39;49m(\n\u001b[1;32m 860\u001b[0m handle,\n\u001b[1;32m 861\u001b[0m ioargs\u001b[39m.\u001b[39;49mmode,\n\u001b[1;32m 862\u001b[0m encoding\u001b[39m=\u001b[39;49mioargs\u001b[39m.\u001b[39;49mencoding,\n\u001b[1;32m 863\u001b[0m errors\u001b[39m=\u001b[39;49merrors,\n\u001b[1;32m 864\u001b[0m newline\u001b[39m=\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39m\"\u001b[39;49m,\n\u001b[1;32m 865\u001b[0m )\n\u001b[1;32m 866\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 867\u001b[0m \u001b[39m# Binary mode\u001b[39;00m\n\u001b[1;32m 868\u001b[0m handle \u001b[39m=\u001b[39m \u001b[39mopen\u001b[39m(handle, ioargs\u001b[39m.\u001b[39mmode)\n","\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/kaggle/input/tmdb-movie-metadata/tmdb_5000_movies.csv'"]}],"source":["movies = pd.read_csv('/home/oem/Downloads/archive (3) (1)/tmdb_5000_movies.csv')\n","credits = pd.read_csv('/home/oem/Downloads/archive (3) (1)/tmdb_5000_credits.csv') "]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:36:33.757778Z","iopub.status.busy":"2021-06-21T12:36:33.757346Z","iopub.status.idle":"2021-06-21T12:36:33.781729Z","shell.execute_reply":"2021-06-21T12:36:33.780738Z","shell.execute_reply.started":"2021-06-21T12:36:33.757743Z"},"trusted":true},"outputs":[{"data":{"text/html":["
\n","\n","
\n"," \n"," \n"," | \n"," budget | \n"," genres | \n"," homepage | \n"," id | \n"," keywords | \n"," original_language | \n"," original_title | \n"," overview | \n"," popularity | \n"," production_companies | \n"," production_countries | \n"," release_date | \n"," revenue | \n"," runtime | \n"," spoken_languages | \n"," status | \n"," tagline | \n"," title | \n"," vote_average | \n"," vote_count | \n","
\n"," \n"," \n"," \n"," 0 | \n"," 237000000 | \n"," [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... | \n"," http://www.avatarmovie.com/ | \n"," 19995 | \n"," [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... | \n"," en | \n"," Avatar | \n"," In the 22nd century, a paraplegic Marine is di... | \n"," 150.437577 | \n"," [{\"name\": \"Ingenious Film Partners\", \"id\": 289... | \n"," [{\"iso_3166_1\": \"US\", \"name\": \"United States o... | \n"," 2009-12-10 | \n"," 2787965087 | \n"," 162.0 | \n"," [{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso... | \n"," Released | \n"," Enter the World of Pandora. | \n"," Avatar | \n"," 7.2 | \n"," 11800 | \n","
\n"," \n"," 1 | \n"," 300000000 | \n"," [{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"... | \n"," http://disney.go.com/disneypictures/pirates/ | \n"," 285 | \n"," [{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... | \n"," en | \n"," Pirates of the Caribbean: At World's End | \n"," Captain Barbossa, long believed to be dead, ha... | \n"," 139.082615 | \n"," [{\"name\": \"Walt Disney Pictures\", \"id\": 2}, {\"... | \n"," [{\"iso_3166_1\": \"US\", \"name\": \"United States o... | \n"," 2007-05-19 | \n"," 961000000 | \n"," 169.0 | \n"," [{\"iso_639_1\": \"en\", \"name\": \"English\"}] | \n"," Released | \n"," At the end of the world, the adventure begins. | \n"," Pirates of the Caribbean: At World's End | \n"," 6.9 | \n"," 4500 | \n","
\n"," \n","
\n","
"],"text/plain":[" budget genres \\\n","0 237000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n","1 300000000 [{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"... \n","\n"," homepage id \\\n","0 http://www.avatarmovie.com/ 19995 \n","1 http://disney.go.com/disneypictures/pirates/ 285 \n","\n"," keywords original_language \\\n","0 [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... en \n","1 [{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... en \n","\n"," original_title \\\n","0 Avatar \n","1 Pirates of the Caribbean: At World's End \n","\n"," overview popularity \\\n","0 In the 22nd century, a paraplegic Marine is di... 150.437577 \n","1 Captain Barbossa, long believed to be dead, ha... 139.082615 \n","\n"," production_companies \\\n","0 [{\"name\": \"Ingenious Film Partners\", \"id\": 289... \n","1 [{\"name\": \"Walt Disney Pictures\", \"id\": 2}, {\"... \n","\n"," production_countries release_date revenue \\\n","0 [{\"iso_3166_1\": \"US\", \"name\": \"United States o... 2009-12-10 2787965087 \n","1 [{\"iso_3166_1\": \"US\", \"name\": \"United States o... 2007-05-19 961000000 \n","\n"," runtime spoken_languages status \\\n","0 162.0 [{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso... Released \n","1 169.0 [{\"iso_639_1\": \"en\", \"name\": \"English\"}] Released \n","\n"," tagline \\\n","0 Enter the World of Pandora. \n","1 At the end of the world, the adventure begins. \n","\n"," title vote_average vote_count \n","0 Avatar 7.2 11800 \n","1 Pirates of the Caribbean: At World's End 6.9 4500 "]},"execution_count":31,"metadata":{},"output_type":"execute_result"}],"source":["movies.head(2)"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:33:06.308311Z","iopub.status.busy":"2021-06-21T12:33:06.307921Z","iopub.status.idle":"2021-06-21T12:33:06.316052Z","shell.execute_reply":"2021-06-21T12:33:06.314903Z","shell.execute_reply.started":"2021-06-21T12:33:06.308279Z"},"trusted":true},"outputs":[{"data":{"text/plain":["(4803, 20)"]},"execution_count":4,"metadata":{},"output_type":"execute_result"}],"source":["movies.shape"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:33:08.787791Z","iopub.status.busy":"2021-06-21T12:33:08.787389Z","iopub.status.idle":"2021-06-21T12:33:08.800864Z","shell.execute_reply":"2021-06-21T12:33:08.799834Z","shell.execute_reply.started":"2021-06-21T12:33:08.787758Z"},"trusted":true},"outputs":[{"data":{"text/html":["\n","\n","
\n"," \n"," \n"," | \n"," movie_id | \n"," title | \n"," cast | \n"," crew | \n","
\n"," \n"," \n"," \n"," 0 | \n"," 19995 | \n"," Avatar | \n"," [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... | \n"," [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... | \n","
\n"," \n"," 1 | \n"," 285 | \n"," Pirates of the Caribbean: At World's End | \n"," [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... | \n"," [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... | \n","
\n"," \n"," 2 | \n"," 206647 | \n"," Spectre | \n"," [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... | \n"," [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... | \n","
\n"," \n"," 3 | \n"," 49026 | \n"," The Dark Knight Rises | \n"," [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... | \n"," [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... | \n","
\n"," \n"," 4 | \n"," 49529 | \n"," John Carter | \n"," [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... | \n"," [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... | \n","
\n"," \n","
\n","
"],"text/plain":[" movie_id title \\\n","0 19995 Avatar \n","1 285 Pirates of the Caribbean: At World's End \n","2 206647 Spectre \n","3 49026 The Dark Knight Rises \n","4 49529 John Carter \n","\n"," cast \\\n","0 [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... \n","1 [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... \n","2 [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... \n","3 [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... \n","4 [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... \n","\n"," crew \n","0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n","1 [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... \n","2 [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... \n","3 [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... \n","4 [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... "]},"execution_count":5,"metadata":{},"output_type":"execute_result"}],"source":["credits.head()"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:36:38.687005Z","iopub.status.busy":"2021-06-21T12:36:38.686521Z","iopub.status.idle":"2021-06-21T12:36:38.713343Z","shell.execute_reply":"2021-06-21T12:36:38.711939Z","shell.execute_reply.started":"2021-06-21T12:36:38.686963Z"},"trusted":true},"outputs":[],"source":["movies = movies.merge(credits,on='title')"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-19T12:48:23.470754Z","iopub.status.busy":"2021-06-19T12:48:23.470187Z","iopub.status.idle":"2021-06-19T12:48:23.5041Z","shell.execute_reply":"2021-06-19T12:48:23.503327Z","shell.execute_reply.started":"2021-06-19T12:48:23.470724Z"},"trusted":true},"outputs":[],"source":["movies.head()\n","# budget\n","# homepage\n","# id\n","# original_language\n","# original_title\n","# popularity\n","# production_comapny\n","# production_countries\n","# release-date(not sure)"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:36:41.393733Z","iopub.status.busy":"2021-06-21T12:36:41.393326Z","iopub.status.idle":"2021-06-21T12:36:41.406883Z","shell.execute_reply":"2021-06-21T12:36:41.405822Z","shell.execute_reply.started":"2021-06-21T12:36:41.393699Z"},"trusted":true},"outputs":[],"source":["movies = movies[['movie_id','title','overview','genres','keywords','cast','crew']]"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:33:39.517061Z","iopub.status.busy":"2021-06-21T12:33:39.516481Z","iopub.status.idle":"2021-06-21T12:33:39.532499Z","shell.execute_reply":"2021-06-21T12:33:39.531584Z","shell.execute_reply.started":"2021-06-21T12:33:39.517012Z"},"trusted":true},"outputs":[{"data":{"text/html":["\n","\n","
\n"," \n"," \n"," | \n"," movie_id | \n"," title | \n"," overview | \n"," genres | \n"," keywords | \n"," cast | \n"," crew | \n","
\n"," \n"," \n"," \n"," 0 | \n"," 19995 | \n"," Avatar | \n"," In the 22nd century, a paraplegic Marine is di... | \n"," [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... | \n"," [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... | \n"," [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... | \n"," [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... | \n","
\n"," \n"," 1 | \n"," 285 | \n"," Pirates of the Caribbean: At World's End | \n"," Captain Barbossa, long believed to be dead, ha... | \n"," [{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"... | \n"," [{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... | \n"," [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... | \n"," [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... | \n","
\n"," \n"," 2 | \n"," 206647 | \n"," Spectre | \n"," A cryptic message from Bond’s past sends him o... | \n"," [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... | \n"," [{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name... | \n"," [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... | \n"," [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... | \n","
\n"," \n"," 3 | \n"," 49026 | \n"," The Dark Knight Rises | \n"," Following the death of District Attorney Harve... | \n"," [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 80, \"nam... | \n"," [{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,... | \n"," [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... | \n"," [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... | \n","
\n"," \n"," 4 | \n"," 49529 | \n"," John Carter | \n"," John Carter is a war-weary, former military ca... | \n"," [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... | \n"," [{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":... | \n"," [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... | \n"," [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... | \n","
\n"," \n","
\n","
"],"text/plain":[" movie_id title \\\n","0 19995 Avatar \n","1 285 Pirates of the Caribbean: At World's End \n","2 206647 Spectre \n","3 49026 The Dark Knight Rises \n","4 49529 John Carter \n","\n"," overview \\\n","0 In the 22nd century, a paraplegic Marine is di... \n","1 Captain Barbossa, long believed to be dead, ha... \n","2 A cryptic message from Bond’s past sends him o... \n","3 Following the death of District Attorney Harve... \n","4 John Carter is a war-weary, former military ca... \n","\n"," genres \\\n","0 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n","1 [{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"... \n","2 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n","3 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 80, \"nam... \n","4 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n","\n"," keywords \\\n","0 [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... \n","1 [{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... \n","2 [{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name... \n","3 [{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,... \n","4 [{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":... \n","\n"," cast \\\n","0 [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... \n","1 [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... \n","2 [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... \n","3 [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... \n","4 [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... \n","\n"," crew \n","0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n","1 [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... \n","2 [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... \n","3 [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... \n","4 [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... "]},"execution_count":8,"metadata":{},"output_type":"execute_result"}],"source":["movies.head()"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:34:19.382856Z","iopub.status.busy":"2021-06-21T12:34:19.382331Z","iopub.status.idle":"2021-06-21T12:34:19.387416Z","shell.execute_reply":"2021-06-21T12:34:19.386451Z","shell.execute_reply.started":"2021-06-21T12:34:19.382822Z"},"trusted":true},"outputs":[],"source":["import ast"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:36:47.540453Z","iopub.status.busy":"2021-06-21T12:36:47.539904Z","iopub.status.idle":"2021-06-21T12:36:47.545014Z","shell.execute_reply":"2021-06-21T12:36:47.544243Z","shell.execute_reply.started":"2021-06-21T12:36:47.540418Z"},"trusted":true},"outputs":[],"source":["def convert(text):\n"," L = []\n"," for i in ast.literal_eval(text):\n"," L.append(i['name']) \n"," return L "]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:36:50.059538Z","iopub.status.busy":"2021-06-21T12:36:50.059006Z","iopub.status.idle":"2021-06-21T12:36:50.073095Z","shell.execute_reply":"2021-06-21T12:36:50.071577Z","shell.execute_reply.started":"2021-06-21T12:36:50.059504Z"},"trusted":true},"outputs":[],"source":["movies.dropna(inplace=True)"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:36:52.344121Z","iopub.status.busy":"2021-06-21T12:36:52.343645Z","iopub.status.idle":"2021-06-21T12:36:52.523910Z","shell.execute_reply":"2021-06-21T12:36:52.522805Z","shell.execute_reply.started":"2021-06-21T12:36:52.344082Z"},"trusted":true},"outputs":[{"data":{"text/html":["\n","\n","
\n"," \n"," \n"," | \n"," movie_id | \n"," title | \n"," overview | \n"," genres | \n"," keywords | \n"," cast | \n"," crew | \n","
\n"," \n"," \n"," \n"," 0 | \n"," 19995 | \n"," Avatar | \n"," In the 22nd century, a paraplegic Marine is di... | \n"," [Action, Adventure, Fantasy, Science Fiction] | \n"," [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... | \n"," [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... | \n"," [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... | \n","
\n"," \n"," 1 | \n"," 285 | \n"," Pirates of the Caribbean: At World's End | \n"," Captain Barbossa, long believed to be dead, ha... | \n"," [Adventure, Fantasy, Action] | \n"," [{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... | \n"," [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... | \n"," [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... | \n","
\n"," \n"," 2 | \n"," 206647 | \n"," Spectre | \n"," A cryptic message from Bond’s past sends him o... | \n"," [Action, Adventure, Crime] | \n"," [{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name... | \n"," [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... | \n"," [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... | \n","
\n"," \n"," 3 | \n"," 49026 | \n"," The Dark Knight Rises | \n"," Following the death of District Attorney Harve... | \n"," [Action, Crime, Drama, Thriller] | \n"," [{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,... | \n"," [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... | \n"," [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... | \n","
\n"," \n"," 4 | \n"," 49529 | \n"," John Carter | \n"," John Carter is a war-weary, former military ca... | \n"," [Action, Adventure, Science Fiction] | \n"," [{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":... | \n"," [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... | \n"," [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... | \n","
\n"," \n","
\n","
"],"text/plain":[" movie_id title \\\n","0 19995 Avatar \n","1 285 Pirates of the Caribbean: At World's End \n","2 206647 Spectre \n","3 49026 The Dark Knight Rises \n","4 49529 John Carter \n","\n"," overview \\\n","0 In the 22nd century, a paraplegic Marine is di... \n","1 Captain Barbossa, long believed to be dead, ha... \n","2 A cryptic message from Bond’s past sends him o... \n","3 Following the death of District Attorney Harve... \n","4 John Carter is a war-weary, former military ca... \n","\n"," genres \\\n","0 [Action, Adventure, Fantasy, Science Fiction] \n","1 [Adventure, Fantasy, Action] \n","2 [Action, Adventure, Crime] \n","3 [Action, Crime, Drama, Thriller] \n","4 [Action, Adventure, Science Fiction] \n","\n"," keywords \\\n","0 [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... \n","1 [{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... \n","2 [{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name... \n","3 [{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,... \n","4 [{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":... \n","\n"," cast \\\n","0 [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... \n","1 [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... \n","2 [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... \n","3 [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... \n","4 [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... \n","\n"," crew \n","0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n","1 [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... \n","2 [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... \n","3 [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... \n","4 [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... "]},"execution_count":36,"metadata":{},"output_type":"execute_result"}],"source":["movies['genres'] = movies['genres'].apply(convert)\n","movies.head()"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:36:55.304439Z","iopub.status.busy":"2021-06-21T12:36:55.304070Z","iopub.status.idle":"2021-06-21T12:36:55.738525Z","shell.execute_reply":"2021-06-21T12:36:55.737123Z","shell.execute_reply.started":"2021-06-21T12:36:55.304408Z"},"trusted":true},"outputs":[{"data":{"text/html":["\n","\n","
\n"," \n"," \n"," | \n"," movie_id | \n"," title | \n"," overview | \n"," genres | \n"," keywords | \n"," cast | \n"," crew | \n","
\n"," \n"," \n"," \n"," 0 | \n"," 19995 | \n"," Avatar | \n"," In the 22nd century, a paraplegic Marine is di... | \n"," [Action, Adventure, Fantasy, Science Fiction] | \n"," [culture clash, future, space war, space colon... | \n"," [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... | \n"," [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... | \n","
\n"," \n"," 1 | \n"," 285 | \n"," Pirates of the Caribbean: At World's End | \n"," Captain Barbossa, long believed to be dead, ha... | \n"," [Adventure, Fantasy, Action] | \n"," [ocean, drug abuse, exotic island, east india ... | \n"," [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... | \n"," [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... | \n","
\n"," \n"," 2 | \n"," 206647 | \n"," Spectre | \n"," A cryptic message from Bond’s past sends him o... | \n"," [Action, Adventure, Crime] | \n"," [spy, based on novel, secret agent, sequel, mi... | \n"," [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... | \n"," [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... | \n","
\n"," \n"," 3 | \n"," 49026 | \n"," The Dark Knight Rises | \n"," Following the death of District Attorney Harve... | \n"," [Action, Crime, Drama, Thriller] | \n"," [dc comics, crime fighter, terrorist, secret i... | \n"," [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... | \n"," [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... | \n","
\n"," \n"," 4 | \n"," 49529 | \n"," John Carter | \n"," John Carter is a war-weary, former military ca... | \n"," [Action, Adventure, Science Fiction] | \n"," [based on novel, mars, medallion, space travel... | \n"," [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... | \n"," [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... | \n","
\n"," \n","
\n","
"],"text/plain":[" movie_id title \\\n","0 19995 Avatar \n","1 285 Pirates of the Caribbean: At World's End \n","2 206647 Spectre \n","3 49026 The Dark Knight Rises \n","4 49529 John Carter \n","\n"," overview \\\n","0 In the 22nd century, a paraplegic Marine is di... \n","1 Captain Barbossa, long believed to be dead, ha... \n","2 A cryptic message from Bond’s past sends him o... \n","3 Following the death of District Attorney Harve... \n","4 John Carter is a war-weary, former military ca... \n","\n"," genres \\\n","0 [Action, Adventure, Fantasy, Science Fiction] \n","1 [Adventure, Fantasy, Action] \n","2 [Action, Adventure, Crime] \n","3 [Action, Crime, Drama, Thriller] \n","4 [Action, Adventure, Science Fiction] \n","\n"," keywords \\\n","0 [culture clash, future, space war, space colon... \n","1 [ocean, drug abuse, exotic island, east india ... \n","2 [spy, based on novel, secret agent, sequel, mi... \n","3 [dc comics, crime fighter, terrorist, secret i... \n","4 [based on novel, mars, medallion, space travel... \n","\n"," cast \\\n","0 [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... \n","1 [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... \n","2 [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... \n","3 [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... \n","4 [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... \n","\n"," crew \n","0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n","1 [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... \n","2 [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... \n","3 [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... \n","4 [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... "]},"execution_count":37,"metadata":{},"output_type":"execute_result"}],"source":["movies['keywords'] = movies['keywords'].apply(convert)\n","movies.head()"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-19T13:07:21.572473Z","iopub.status.busy":"2021-06-19T13:07:21.572154Z","iopub.status.idle":"2021-06-19T13:07:21.578686Z","shell.execute_reply":"2021-06-19T13:07:21.577661Z","shell.execute_reply.started":"2021-06-19T13:07:21.572446Z"},"trusted":true},"outputs":[],"source":["import ast\n","ast.literal_eval('[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"name\": \"Fantasy\"}, {\"id\": 878, \"name\": \"Science Fiction\"}]')"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:36:59.511226Z","iopub.status.busy":"2021-06-21T12:36:59.510859Z","iopub.status.idle":"2021-06-21T12:36:59.517043Z","shell.execute_reply":"2021-06-21T12:36:59.515878Z","shell.execute_reply.started":"2021-06-21T12:36:59.511192Z"},"trusted":true},"outputs":[],"source":["def convert3(text):\n"," L = []\n"," counter = 0\n"," for i in ast.literal_eval(text):\n"," if counter < 3:\n"," L.append(i['name'])\n"," counter+=1\n"," return L "]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:37:00.829409Z","iopub.status.busy":"2021-06-21T12:37:00.828661Z","iopub.status.idle":"2021-06-21T12:37:04.117090Z","shell.execute_reply":"2021-06-21T12:37:04.115822Z","shell.execute_reply.started":"2021-06-21T12:37:00.829355Z"},"trusted":true},"outputs":[{"data":{"text/html":["\n","\n","
\n"," \n"," \n"," | \n"," movie_id | \n"," title | \n"," overview | \n"," genres | \n"," keywords | \n"," cast | \n"," crew | \n","
\n"," \n"," \n"," \n"," 0 | \n"," 19995 | \n"," Avatar | \n"," In the 22nd century, a paraplegic Marine is di... | \n"," [Action, Adventure, Fantasy, Science Fiction] | \n"," [culture clash, future, space war, space colon... | \n"," [Sam Worthington, Zoe Saldana, Sigourney Weave... | \n"," [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... | \n","
\n"," \n"," 1 | \n"," 285 | \n"," Pirates of the Caribbean: At World's End | \n"," Captain Barbossa, long believed to be dead, ha... | \n"," [Adventure, Fantasy, Action] | \n"," [ocean, drug abuse, exotic island, east india ... | \n"," [Johnny Depp, Orlando Bloom, Keira Knightley, ... | \n"," [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... | \n","
\n"," \n"," 2 | \n"," 206647 | \n"," Spectre | \n"," A cryptic message from Bond’s past sends him o... | \n"," [Action, Adventure, Crime] | \n"," [spy, based on novel, secret agent, sequel, mi... | \n"," [Daniel Craig, Christoph Waltz, Léa Seydoux, R... | \n"," [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... | \n","
\n"," \n"," 3 | \n"," 49026 | \n"," The Dark Knight Rises | \n"," Following the death of District Attorney Harve... | \n"," [Action, Crime, Drama, Thriller] | \n"," [dc comics, crime fighter, terrorist, secret i... | \n"," [Christian Bale, Michael Caine, Gary Oldman, A... | \n"," [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... | \n","
\n"," \n"," 4 | \n"," 49529 | \n"," John Carter | \n"," John Carter is a war-weary, former military ca... | \n"," [Action, Adventure, Science Fiction] | \n"," [based on novel, mars, medallion, space travel... | \n"," [Taylor Kitsch, Lynn Collins, Samantha Morton,... | \n"," [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... | \n","
\n"," \n","
\n","
"],"text/plain":[" movie_id title \\\n","0 19995 Avatar \n","1 285 Pirates of the Caribbean: At World's End \n","2 206647 Spectre \n","3 49026 The Dark Knight Rises \n","4 49529 John Carter \n","\n"," overview \\\n","0 In the 22nd century, a paraplegic Marine is di... \n","1 Captain Barbossa, long believed to be dead, ha... \n","2 A cryptic message from Bond’s past sends him o... \n","3 Following the death of District Attorney Harve... \n","4 John Carter is a war-weary, former military ca... \n","\n"," genres \\\n","0 [Action, Adventure, Fantasy, Science Fiction] \n","1 [Adventure, Fantasy, Action] \n","2 [Action, Adventure, Crime] \n","3 [Action, Crime, Drama, Thriller] \n","4 [Action, Adventure, Science Fiction] \n","\n"," keywords \\\n","0 [culture clash, future, space war, space colon... \n","1 [ocean, drug abuse, exotic island, east india ... \n","2 [spy, based on novel, secret agent, sequel, mi... \n","3 [dc comics, crime fighter, terrorist, secret i... \n","4 [based on novel, mars, medallion, space travel... \n","\n"," cast \\\n","0 [Sam Worthington, Zoe Saldana, Sigourney Weave... \n","1 [Johnny Depp, Orlando Bloom, Keira Knightley, ... \n","2 [Daniel Craig, Christoph Waltz, Léa Seydoux, R... \n","3 [Christian Bale, Michael Caine, Gary Oldman, A... \n","4 [Taylor Kitsch, Lynn Collins, Samantha Morton,... \n","\n"," crew \n","0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n","1 [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... \n","2 [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... \n","3 [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... \n","4 [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... "]},"execution_count":39,"metadata":{},"output_type":"execute_result"}],"source":["movies['cast'] = movies['cast'].apply(convert)\n","movies.head()"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:37:07.352886Z","iopub.status.busy":"2021-06-21T12:37:07.352464Z","iopub.status.idle":"2021-06-21T12:37:07.367808Z","shell.execute_reply":"2021-06-21T12:37:07.366250Z","shell.execute_reply.started":"2021-06-21T12:37:07.352854Z"},"trusted":true},"outputs":[],"source":["movies['cast'] = movies['cast'].apply(lambda x:x[0:3])"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:37:09.763317Z","iopub.status.busy":"2021-06-21T12:37:09.762909Z","iopub.status.idle":"2021-06-21T12:37:09.770917Z","shell.execute_reply":"2021-06-21T12:37:09.770002Z","shell.execute_reply.started":"2021-06-21T12:37:09.763278Z"},"trusted":true},"outputs":[],"source":["def fetch_director(text):\n"," L = []\n"," for i in ast.literal_eval(text):\n"," if i['job'] == 'Director':\n"," L.append(i['name'])\n"," return L "]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:37:12.190468Z","iopub.status.busy":"2021-06-21T12:37:12.189921Z","iopub.status.idle":"2021-06-21T12:37:15.825662Z","shell.execute_reply":"2021-06-21T12:37:15.824562Z","shell.execute_reply.started":"2021-06-21T12:37:12.190407Z"},"trusted":true},"outputs":[],"source":["movies['crew'] = movies['crew'].apply(fetch_director)"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:34:54.994779Z","iopub.status.busy":"2021-06-21T12:34:54.994397Z","iopub.status.idle":"2021-06-21T12:34:55.019276Z","shell.execute_reply":"2021-06-21T12:34:55.017718Z","shell.execute_reply.started":"2021-06-21T12:34:54.994738Z"},"trusted":true},"outputs":[{"data":{"text/html":["\n","\n","
\n"," \n"," \n"," | \n"," movie_id | \n"," title | \n"," overview | \n"," genres | \n"," keywords | \n"," cast | \n"," crew | \n","
\n"," \n"," \n"," \n"," 1183 | \n"," 9889 | \n"," Shallow Hal | \n"," A shallow man falls in love with a 300 pound w... | \n"," [Comedy, Romance] | \n"," [overweight, beauty, hypnosis, overweight man,... | \n"," [Gwyneth Paltrow, Jack Black, Jason Alexander] | \n"," [Bobby Farrelly, Peter Farrelly] | \n","
\n"," \n"," 4215 | \n"," 15976 | \n"," The Bubble | \n"," The movie follows a group of young friends in ... | \n"," [Drama, Romance] | \n"," [gay] | \n"," [Ohad Knoller, Yousef Sweid, Daniella Wircer] | \n"," [Eytan Fox] | \n","
\n"," \n"," 1571 | \n"," 22947 | \n"," Up in the Air | \n"," George Clooney plays the dry cynical character... | \n"," [Drama, Romance] | \n"," [suitcase, business, omaha, on the road, downs... | \n"," [George Clooney, Vera Farmiga, Anna Kendrick] | \n"," [Jason Reitman] | \n","
\n"," \n"," 205 | \n"," 58574 | \n"," Sherlock Holmes: A Game of Shadows | \n"," There is a new criminal mastermind at large (P... | \n"," [Adventure, Action, Crime, Mystery] | \n"," [detective inspector, steampunk, criminal mast... | \n"," [Robert Downey Jr., Jude Law, Jared Harris] | \n"," [Guy Ritchie] | \n","
\n"," \n"," 352 | \n"," 10674 | \n"," Mulan | \n"," A tomboyish girl disguises herself as a young ... | \n"," [Animation, Family, Adventure] | \n"," [homeland, musical, training, daughter, cricke... | \n"," [Eddie Murphy, Jackie Chan, Ming-Na Wen] | \n"," [Tony Bancroft, Barry Cook] | \n","
\n"," \n","
\n","
"],"text/plain":[" movie_id title \\\n","1183 9889 Shallow Hal \n","4215 15976 The Bubble \n","1571 22947 Up in the Air \n","205 58574 Sherlock Holmes: A Game of Shadows \n","352 10674 Mulan \n","\n"," overview \\\n","1183 A shallow man falls in love with a 300 pound w... \n","4215 The movie follows a group of young friends in ... \n","1571 George Clooney plays the dry cynical character... \n","205 There is a new criminal mastermind at large (P... \n","352 A tomboyish girl disguises herself as a young ... \n","\n"," genres \\\n","1183 [Comedy, Romance] \n","4215 [Drama, Romance] \n","1571 [Drama, Romance] \n","205 [Adventure, Action, Crime, Mystery] \n","352 [Animation, Family, Adventure] \n","\n"," keywords \\\n","1183 [overweight, beauty, hypnosis, overweight man,... \n","4215 [gay] \n","1571 [suitcase, business, omaha, on the road, downs... \n","205 [detective inspector, steampunk, criminal mast... \n","352 [homeland, musical, training, daughter, cricke... \n","\n"," cast \\\n","1183 [Gwyneth Paltrow, Jack Black, Jason Alexander] \n","4215 [Ohad Knoller, Yousef Sweid, Daniella Wircer] \n","1571 [George Clooney, Vera Farmiga, Anna Kendrick] \n","205 [Robert Downey Jr., Jude Law, Jared Harris] \n","352 [Eddie Murphy, Jackie Chan, Ming-Na Wen] \n","\n"," crew \n","1183 [Bobby Farrelly, Peter Farrelly] \n","4215 [Eytan Fox] \n","1571 [Jason Reitman] \n","205 [Guy Ritchie] \n","352 [Tony Bancroft, Barry Cook] "]},"execution_count":22,"metadata":{},"output_type":"execute_result"}],"source":["#movies['overview'] = movies['overview'].apply(lambda x:x.split())\n","movies.sample(5)"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:37:20.073320Z","iopub.status.busy":"2021-06-21T12:37:20.072749Z","iopub.status.idle":"2021-06-21T12:37:20.079118Z","shell.execute_reply":"2021-06-21T12:37:20.077997Z","shell.execute_reply.started":"2021-06-21T12:37:20.073270Z"},"trusted":true},"outputs":[],"source":["def collapse(L):\n"," L1 = []\n"," for i in L:\n"," L1.append(i.replace(\" \",\"\"))\n"," return L1"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:37:21.283329Z","iopub.status.busy":"2021-06-21T12:37:21.282768Z","iopub.status.idle":"2021-06-21T12:37:21.486755Z","shell.execute_reply":"2021-06-21T12:37:21.485878Z","shell.execute_reply.started":"2021-06-21T12:37:21.283292Z"},"trusted":true},"outputs":[],"source":["movies['cast'] = movies['cast'].apply(collapse)\n","movies['crew'] = movies['crew'].apply(collapse)\n","movies['genres'] = movies['genres'].apply(collapse)\n","movies['keywords'] = movies['keywords'].apply(collapse)"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:35:23.278589Z","iopub.status.busy":"2021-06-21T12:35:23.278025Z","iopub.status.idle":"2021-06-21T12:35:23.311346Z","shell.execute_reply":"2021-06-21T12:35:23.309971Z","shell.execute_reply.started":"2021-06-21T12:35:23.278539Z"},"trusted":true},"outputs":[{"data":{"text/html":["\n","\n","
\n"," \n"," \n"," | \n"," movie_id | \n"," title | \n"," overview | \n"," genres | \n"," keywords | \n"," cast | \n"," crew | \n","
\n"," \n"," \n"," \n"," 0 | \n"," 19995 | \n"," Avatar | \n"," In the 22nd century, a paraplegic Marine is di... | \n"," [Action, Adventure, Fantasy, ScienceFiction] | \n"," [cultureclash, future, spacewar, spacecolony, ... | \n"," [SamWorthington, ZoeSaldana, SigourneyWeaver] | \n"," [JamesCameron] | \n","
\n"," \n"," 1 | \n"," 285 | \n"," Pirates of the Caribbean: At World's End | \n"," Captain Barbossa, long believed to be dead, ha... | \n"," [Adventure, Fantasy, Action] | \n"," [ocean, drugabuse, exoticisland, eastindiatrad... | \n"," [JohnnyDepp, OrlandoBloom, KeiraKnightley] | \n"," [GoreVerbinski] | \n","
\n"," \n"," 2 | \n"," 206647 | \n"," Spectre | \n"," A cryptic message from Bond’s past sends him o... | \n"," [Action, Adventure, Crime] | \n"," [spy, basedonnovel, secretagent, sequel, mi6, ... | \n"," [DanielCraig, ChristophWaltz, LéaSeydoux] | \n"," [SamMendes] | \n","
\n"," \n"," 3 | \n"," 49026 | \n"," The Dark Knight Rises | \n"," Following the death of District Attorney Harve... | \n"," [Action, Crime, Drama, Thriller] | \n"," [dccomics, crimefighter, terrorist, secretiden... | \n"," [ChristianBale, MichaelCaine, GaryOldman] | \n"," [ChristopherNolan] | \n","
\n"," \n"," 4 | \n"," 49529 | \n"," John Carter | \n"," John Carter is a war-weary, former military ca... | \n"," [Action, Adventure, ScienceFiction] | \n"," [basedonnovel, mars, medallion, spacetravel, p... | \n"," [TaylorKitsch, LynnCollins, SamanthaMorton] | \n"," [AndrewStanton] | \n","
\n"," \n","
\n","
"],"text/plain":[" movie_id title \\\n","0 19995 Avatar \n","1 285 Pirates of the Caribbean: At World's End \n","2 206647 Spectre \n","3 49026 The Dark Knight Rises \n","4 49529 John Carter \n","\n"," overview \\\n","0 In the 22nd century, a paraplegic Marine is di... \n","1 Captain Barbossa, long believed to be dead, ha... \n","2 A cryptic message from Bond’s past sends him o... \n","3 Following the death of District Attorney Harve... \n","4 John Carter is a war-weary, former military ca... \n","\n"," genres \\\n","0 [Action, Adventure, Fantasy, ScienceFiction] \n","1 [Adventure, Fantasy, Action] \n","2 [Action, Adventure, Crime] \n","3 [Action, Crime, Drama, Thriller] \n","4 [Action, Adventure, ScienceFiction] \n","\n"," keywords \\\n","0 [cultureclash, future, spacewar, spacecolony, ... \n","1 [ocean, drugabuse, exoticisland, eastindiatrad... \n","2 [spy, basedonnovel, secretagent, sequel, mi6, ... \n","3 [dccomics, crimefighter, terrorist, secretiden... \n","4 [basedonnovel, mars, medallion, spacetravel, p... \n","\n"," cast crew \n","0 [SamWorthington, ZoeSaldana, SigourneyWeaver] [JamesCameron] \n","1 [JohnnyDepp, OrlandoBloom, KeiraKnightley] [GoreVerbinski] \n","2 [DanielCraig, ChristophWaltz, LéaSeydoux] [SamMendes] \n","3 [ChristianBale, MichaelCaine, GaryOldman] [ChristopherNolan] \n","4 [TaylorKitsch, LynnCollins, SamanthaMorton] [AndrewStanton] "]},"execution_count":26,"metadata":{},"output_type":"execute_result"}],"source":["movies.head()"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:37:31.936583Z","iopub.status.busy":"2021-06-21T12:37:31.936003Z","iopub.status.idle":"2021-06-21T12:37:31.975155Z","shell.execute_reply":"2021-06-21T12:37:31.973928Z","shell.execute_reply.started":"2021-06-21T12:37:31.936546Z"},"trusted":true},"outputs":[],"source":["movies['overview'] = movies['overview'].apply(lambda x:x.split())"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:37:34.466349Z","iopub.status.busy":"2021-06-21T12:37:34.465925Z","iopub.status.idle":"2021-06-21T12:37:34.572742Z","shell.execute_reply":"2021-06-21T12:37:34.571676Z","shell.execute_reply.started":"2021-06-21T12:37:34.466313Z"},"trusted":true},"outputs":[],"source":["movies['tags'] = movies['overview'] + movies['genres'] + movies['keywords'] + movies['cast'] + movies['crew']"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:37:40.975174Z","iopub.status.busy":"2021-06-21T12:37:40.974644Z","iopub.status.idle":"2021-06-21T12:37:40.981843Z","shell.execute_reply":"2021-06-21T12:37:40.981059Z","shell.execute_reply.started":"2021-06-21T12:37:40.975140Z"},"trusted":true},"outputs":[],"source":["new = movies.drop(columns=['overview','genres','keywords','cast','crew'])\n","#new.head()"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:38:00.131473Z","iopub.status.busy":"2021-06-21T12:38:00.130879Z","iopub.status.idle":"2021-06-21T12:38:00.160438Z","shell.execute_reply":"2021-06-21T12:38:00.159476Z","shell.execute_reply.started":"2021-06-21T12:38:00.131439Z"},"trusted":true},"outputs":[{"data":{"text/html":["\n","\n","
\n"," \n"," \n"," | \n"," movie_id | \n"," title | \n"," tags | \n","
\n"," \n"," \n"," \n"," 0 | \n"," 19995 | \n"," Avatar | \n"," In the 22nd century, a paraplegic Marine is di... | \n","
\n"," \n"," 1 | \n"," 285 | \n"," Pirates of the Caribbean: At World's End | \n"," Captain Barbossa, long believed to be dead, ha... | \n","
\n"," \n"," 2 | \n"," 206647 | \n"," Spectre | \n"," A cryptic message from Bond’s past sends him o... | \n","
\n"," \n"," 3 | \n"," 49026 | \n"," The Dark Knight Rises | \n"," Following the death of District Attorney Harve... | \n","
\n"," \n"," 4 | \n"," 49529 | \n"," John Carter | \n"," John Carter is a war-weary, former military ca... | \n","
\n"," \n","
\n","
"],"text/plain":[" movie_id title \\\n","0 19995 Avatar \n","1 285 Pirates of the Caribbean: At World's End \n","2 206647 Spectre \n","3 49026 The Dark Knight Rises \n","4 49529 John Carter \n","\n"," tags \n","0 In the 22nd century, a paraplegic Marine is di... \n","1 Captain Barbossa, long believed to be dead, ha... \n","2 A cryptic message from Bond’s past sends him o... \n","3 Following the death of District Attorney Harve... \n","4 John Carter is a war-weary, former military ca... "]},"execution_count":48,"metadata":{},"output_type":"execute_result"}],"source":["new['tags'] = new['tags'].apply(lambda x: \" \".join(x))\n","new.head()"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:38:06.545110Z","iopub.status.busy":"2021-06-21T12:38:06.544599Z","iopub.status.idle":"2021-06-21T12:38:07.488307Z","shell.execute_reply":"2021-06-21T12:38:07.487238Z","shell.execute_reply.started":"2021-06-21T12:38:06.545079Z"},"trusted":true},"outputs":[],"source":["from sklearn.feature_extraction.text import CountVectorizer\n","cv = CountVectorizer(max_features=5000,stop_words='english')\n"," "]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:38:10.164314Z","iopub.status.busy":"2021-06-21T12:38:10.163889Z","iopub.status.idle":"2021-06-21T12:38:10.821200Z","shell.execute_reply":"2021-06-21T12:38:10.820175Z","shell.execute_reply.started":"2021-06-21T12:38:10.164279Z"},"trusted":true},"outputs":[],"source":["vector = cv.fit_transform(new['tags']).toarray()"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-19T14:00:41.894747Z","iopub.status.busy":"2021-06-19T14:00:41.894223Z","iopub.status.idle":"2021-06-19T14:00:41.900786Z","shell.execute_reply":"2021-06-19T14:00:41.899989Z","shell.execute_reply.started":"2021-06-19T14:00:41.894699Z"},"trusted":true},"outputs":[],"source":["vector.shape"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:38:13.339451Z","iopub.status.busy":"2021-06-21T12:38:13.339041Z","iopub.status.idle":"2021-06-21T12:38:13.390575Z","shell.execute_reply":"2021-06-21T12:38:13.389373Z","shell.execute_reply.started":"2021-06-21T12:38:13.339412Z"},"trusted":true},"outputs":[],"source":["from sklearn.metrics.pairwise import cosine_similarity"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:38:15.770001Z","iopub.status.busy":"2021-06-21T12:38:15.769495Z","iopub.status.idle":"2021-06-21T12:38:18.170463Z","shell.execute_reply":"2021-06-21T12:38:18.169319Z","shell.execute_reply.started":"2021-06-21T12:38:15.769960Z"},"trusted":true},"outputs":[],"source":["similarity = cosine_similarity(vector)"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-19T14:06:45.473087Z","iopub.status.busy":"2021-06-19T14:06:45.472777Z","iopub.status.idle":"2021-06-19T14:06:45.479647Z","shell.execute_reply":"2021-06-19T14:06:45.478831Z","shell.execute_reply.started":"2021-06-19T14:06:45.473061Z"},"trusted":true},"outputs":[],"source":["similarity"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-19T14:08:46.716222Z","iopub.status.busy":"2021-06-19T14:08:46.7159Z","iopub.status.idle":"2021-06-19T14:08:46.7239Z","shell.execute_reply":"2021-06-19T14:08:46.722946Z","shell.execute_reply.started":"2021-06-19T14:08:46.716196Z"},"trusted":true},"outputs":[],"source":["new[new['title'] == 'The Lego Movie'].index[0]"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:38:22.542900Z","iopub.status.busy":"2021-06-21T12:38:22.542487Z","iopub.status.idle":"2021-06-21T12:38:22.549786Z","shell.execute_reply":"2021-06-21T12:38:22.548271Z","shell.execute_reply.started":"2021-06-21T12:38:22.542867Z"},"trusted":true},"outputs":[],"source":["def recommend(movie):\n"," index = new[new['title'] == movie].index[0]\n"," distances = sorted(list(enumerate(similarity[index])),reverse=True,key = lambda x: x[1])\n"," for i in distances[1:6]:\n"," print(new.iloc[i[0]].title)\n"," \n"," "]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:38:24.914650Z","iopub.status.busy":"2021-06-21T12:38:24.914258Z","iopub.status.idle":"2021-06-21T12:38:24.930018Z","shell.execute_reply":"2021-06-21T12:38:24.928876Z","shell.execute_reply.started":"2021-06-21T12:38:24.914616Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["Gandhi, My Father\n","The Wind That Shakes the Barley\n","A Passage to India\n","Guiana 1838\n","Ramanujan\n"]}],"source":["recommend('Gandhi')"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:39:59.606924Z","iopub.status.busy":"2021-06-21T12:39:59.606475Z","iopub.status.idle":"2021-06-21T12:39:59.612177Z","shell.execute_reply":"2021-06-21T12:39:59.610858Z","shell.execute_reply.started":"2021-06-21T12:39:59.606890Z"},"trusted":true},"outputs":[],"source":["import pickle"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2021-06-21T12:40:53.373581Z","iopub.status.busy":"2021-06-21T12:40:53.373186Z","iopub.status.idle":"2021-06-21T12:40:53.784869Z","shell.execute_reply":"2021-06-21T12:40:53.783635Z","shell.execute_reply.started":"2021-06-21T12:40:53.373547Z"},"trusted":true},"outputs":[],"source":["pickle.dump(new,open('movie_list.pkl','wb'))\n","pickle.dump(similarity,open('similarity.pkl','wb'))"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.12"},"vscode":{"interpreter":{"hash":"97cc609b13305c559618ec78a438abc56230b9381f827f22d070313b9a1f3777"}}},"nbformat":4,"nbformat_minor":4}