Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
4,851 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import ast | ||
movies = pd.read_csv('tmdb_5000_movies.csv') | ||
credits = pd.read_csv('tmdb_5000_credits.csv') | ||
|
||
# Merge movies and credits | ||
movies = movies.merge(credits,on='title') | ||
|
||
# list of columns we will keep | ||
# Genres, Original Language, Original Title, Overview, | ||
movies = movies[['title','overview','genres','original_language','cast']] | ||
|
||
|
||
movies.dropna(inplace=True) # removing extra(Null Columns) | ||
(movies.isnull().sum()) | ||
(movies.duplicated().sum()) # Checking for Duplicate Data | ||
|
||
def convertGenres (obj): # A function for retrieving the Genres | ||
L = [] | ||
for i in ast.literal_eval(obj): | ||
L.append(i['name']) | ||
return L | ||
|
||
movies["genres"] = movies['genres'].apply(convertGenres) | ||
|
||
def convertCast (obj): # a function for retreiving the first 3 names from Cast | ||
l=[] | ||
counter = 0 | ||
for i in ast.literal_eval(obj): | ||
if counter !=3: | ||
l.append(i['name']) | ||
counter = counter + 1 | ||
else: | ||
break | ||
return l | ||
movies['cast'] = (movies['cast'].apply(convertCast)) | ||
|
||
print(movies) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.