<jupyter_start><jupyter_text>Project: TMDB Movie Data Investigating  Table of ContentsIntroductionData WranglingExploratory Data AnalysisConclusions  IntroductionThis data set contains information about 10,000 movies collected from The Movie Database (TMDb), including user ratings and revenue.And it contains 21 columns and 10866 rows. Questions:1-Which year has the most movie voting 2-Which year has the most movies releases 3-which year has the most average movies revenue 4-What are the top 10 movies by revenue 5-What are the top 10 movies by votes count 6-What are the top 10 movies by runtime duration 7-What are the top 10 movies by budget 8-What are the top 10 movies by popularity 9-What are the top 10 lowest movies by votes average 10-Is there is correlation between popularity and revenue 11-Who are the most popular directors 12-What are the most popular movie genres<jupyter_code>import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Data Wrangling General PropertiesLoading the csv file and displaying general data overview<jupyter_code>tmdb=pd.read_csv("tmdb-movies.csv")
tmdb.head()

tmdb.info()
tmdb.shape
tmdb.describe()<jupyter_output><empty_output><jupyter_text>This table describes the statistics for each columns in this dataset  Data Cleaning  *Checking and dropping NAN values*Checking and dropping duplicated values*Dropping unwanted columns in this invistgation  >Checking and dropping NAN values<jupyter_code>tmdb.isnull().sum()
tmdb.fillna(0,inplace=True)
tmdb.isnull().sum()<jupyter_output><empty_output><jupyter_text>>Checking and dropping duplicated values<jupyter_code>tmdb.duplicated().sum()
tmdb.drop_duplicates(inplace=True)<jupyter_output><empty_output><jupyter_text>>Dropping unwanted columns in this invistgation<jupyter_code>tmdb.drop(['homepage','cast','tagline','overview','production_companies'],axis=1,inplace=True)
tmdb.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 10865 entries, 0 to 10865
Data columns (total 16 columns):
 #   Column          Non-Null Count  Dtype  
---  ------          --------------  -----  
 0   id              10865 non-null  int64  
 1   imdb_id         10865 non-null  object 
 2   popularity      10865 non-null  float64
 3   budget          10865 non-null  int64  
 4   revenue         10865 non-null  int64  
 5   original_title  10865 non-null  object 
 6   director        10865 non-null  object 
 7   keywords        10865 non-null  object 
 8   runtime         10865 non-null  int64  
 9   genres          10865 non-null  object 
 10  release_date    10865 non-null  object 
 11  vote_count      10865 non-null  int64  
 12  vote_average    10865 non-null  float64
 13  release_year    10865 non-null  int64  
 14  budget_adj      10865 non-null  float64
 15  revenue_adj     10865 non-null  float64
dtypes: float64(4), int64(6), object(6)
memory usage: 1.4+ MB<jupyter_text>Exploratory Data Analysis (Research Question 1):  Which year has the most movie voting<jupyter_code>plt.figure(figsize=(15,10))
sns.barplot(x='release_year',y='vote_count',data=tmdb);
plt.xticks(rotation=90);<jupyter_output><empty_output><jupyter_text>The charts above shows each year movies voting and the year with the most movies votes is 2013 then 2012 then 2014  (Research Question 2): Which year has the most movies releases<jupyter_code>plt.figure(figsize=(15,10))
sns.countplot(tmdb['release_year']);
plt.title('movies released per year',fontsize = 20)
plt.xlabel('release year',fontsize = 15)
plt.ylabel('number of movies',fontsize = 15)
plt.xticks(rotation=90)
plt.show()
most_releasesY=tmdb.groupby('release_year').count()['id']
print(most_releasesY.tail())<jupyter_output>C:\ProgramData\Anaconda3\lib\site-packages\seaborn\_decorators.py:36: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  warnings.warn(<jupyter_text>The charts above shows every year movies releases and the highest movie releases year is 2014 (700 movies) then 2013 (659 movies) then 2015 (629 movies)  (Research Question 3): which year has the most average movies revenue<jupyter_code>tmdb.groupby('release_year')['revenue'].mean().sort_values(ascending=False)
plt.figure(figsize=(15,10))
sns.barplot(x='release_year',y='revenue',data=tmdb);
plt.title('revenue per year')
plt.xticks(rotation=90);<jupyter_output><empty_output><jupyter_text>The charts above shows every year movies revenue and the highest revenue year is 1997 then 2001 then 2002  (Research Question 4): What are the top 10 movies by revenue<jupyter_code>top10revenue=tmdb.nlargest(10,'revenue')[['original_title','revenue']].set_index('original_title')
top10revenue
sns.barplot(x='revenue',y=top10revenue.index,data=top10revenue);
plt.title('top 10 highest revenue movies');<jupyter_output><empty_output><jupyter_text>The charts above shows the the top 10 highest revenue movies and the top 3 are Avatar (total earnings 2.781.505.847 USD) ,Star Wars : The Force Awakens (total earnings 2.068.178.225 USD ) , Titanic (total earnings 1.845.034.188 USD )  (Research Question 5): What are the top 10 movies by votes count<jupyter_code>top10rating=tmdb.nlargest(10,'vote_count')[['original_title','vote_count']].set_index('original_title')
top10rating
sns.pointplot(x='vote_count',y=top10rating.index,data=top10rating);
plt.title('top 10 highest votes movies');<jupyter_output><empty_output><jupyter_text>The charts above shows the the top 10 highest movies by votes count and the top 3 are Inception (9767 votes), The Avengers (8903 votes) , Avatar (8458 votes) .   (Research Question 6): What are the top 10 movies by runtime duration<jupyter_code>top10runtime=tmdb.nlargest(10,'runtime')[['original_title','runtime']].set_index('original_title')
top10runtime
sns.barplot(x='runtime',y=top10runtime.index,data=top10runtime);
plt.title('top 10 highest runtime movies');<jupyter_output><empty_output><jupyter_text>The charts above shows the the top 10 highest runtimes movies and the top 3 are The Story of Film: An Odyssey  with a runtime of 900 minutes (about 15 hours) , Taken with a runtime of 877 minutes (14 hours and 37 minutes) , Band of Brothers with a runtime of 705 minutes(11 hours and 45 minutes).   (Research Question 7): What are the top 10 movies by budget<jupyter_code>top10budget=tmdb.nlargest(10,'budget')[['original_title','budget']].set_index('original_title')
top10budget
sns.barplot(x='budget',y=top10budget.index,data=top10budget);
plt.title('top 10 highest budget movies');<jupyter_output><empty_output><jupyter_text>The charts above shows the the top 10 highest budget movies and the top 3 are The Warrior's Way , Pirates of the Caribbean: On Stranger Tides , Pirates of the Caribbean: At World's End .   (Research Question 8): What are the top 10 movies by popularity<jupyter_code>top10popularity=tmdb.nlargest(10,'popularity')[['original_title','popularity']].set_index('original_title')
top10popularity
sns.barplot(x='popularity',y=top10popularity.index,data=top10popularity);
plt.title('top 10 highest popularity movies');<jupyter_output><empty_output><jupyter_text>The charts above shows the the top 10 highest popularity movies and the top 3 are Jurassic World , Mad Max: Fury Road , Interstellar.  (Research Question 9): What are the top 10 lowest movies by votes average<jupyter_code>top10low_vote=tmdb.nsmallest(10,'vote_average')[['original_title','vote_average']].set_index('original_title')
top10low_vote
sns.barplot(x='vote_average',y=top10low_vote.index,data=top10low_vote);
plt.title('top 10 lowest movies by votes average');<jupyter_output><empty_output><jupyter_text>The charts above shows the the lowest movies by votes average and the lowest 3 are Transmorphers , Manos: The Hands of Fate ,Jurassic Shark.   (Research Question 10): Is there is correlation between popularity and revenue?<jupyter_code>tmdb.plot.scatter(x = 'popularity', y = 'revenue');
sns.lmplot(x = 'popularity', y = 'revenue',data=tmdb);<jupyter_output><empty_output><jupyter_text>There is postive correlation between revenue and popularity which mean when the more revenue means more popularity for the movie  (Research Question 11): Who are the most popular directors<jupyter_code>tmdb['director'].value_counts().head(15).plot.bar(figsize=(15,10));
plt.xlabel('directors',fontsize=12);
plt.ylabel('popularity',fontsize=12);
plt.title('most popular directors',fontsize=20);<jupyter_output><empty_output><jupyter_text>The charts above shows the most popular directors and the top 3 are <NAME> , <NAME> , <NAME>.  (Research Question 11): What are the most popular movie genres<jupyter_code>tmdb["genres"] = tmdb["genres"].astype(str)
def data(genres):
    data_plot = tmdb[genres].str.cat(sep = '|')
    data = pd.Series(data_plot.split('|'))
    info = data.value_counts(ascending=False)
    return info

total_keywords = data('genres')
print(total_keywords)
total_keywords.plot(kind='bar',figsize=(15,10));
plt.xlabel('keywords',fontsize=15);
plt.ylabel('movies number',fontsize=15);
plt.title('number of each genres',fontsize=20);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10188273265196342, 'fraction_numerical': 0.04959655728886498, 'mean_word_length': 5.973743435858965, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 74, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '17', 'dir': 'jupyter-structured-clean-dedup', 'id': '452885', 'license': 'MIT', 'n_tokens_mistral': 3304, 'n_tokens_neox': 2855, 'n_words': 876, 'path': 'the project.ipynb', 'repo_name': 'AhmedElmam/Project-TMDB-Movie-Data-Investigating', 'size': '9317'}