<jupyter_start><jupyter_text>IMDb Movie Assignment You have the data for the 100 top-rated movies from the past decade along with various pieces of information about the movie, its actors, and the voters who have rated these movies online. In this assignment, you will try to find some interesting insights into these movies and their voters, using Python.   Task 1: Reading the data -  Subtask 1.1: Read the Movies Data.Read the movies data file provided and store it in a dataframe `movies`.<jupyter_code># Read the csv file using 'read_csv'. Please write your dataset location here.
movies = pd.read_csv('Movie+Assignment+Data.csv') # Reading Movies Assignment Dataset using pandas read_csv command
movies.head() # printing top 5 movies from the DF to check if the data is loaded correctly<jupyter_output><empty_output><jupyter_text>-   Subtask 1.2: Inspect the DataframeInspect the dataframe for dimensions, null-values, and summary of different numeric columns.<jupyter_code># Check the number of rows and columns in the dataframe

movies.shape #This would return the rows and columns of the movies DF - 100 Rows & 62 Columns
# Check the column-wise info of the dataframe

movies.info() # This would give me the column wise information on the null count and the Dtype for movies DF
# Check the summary for the numeric columns 

movies.describe() #method for calculating numerical values of the DF<jupyter_output><empty_output><jupyter_text>Task 2: Data AnalysisNow that we have loaded the dataset and inspected it, we see that most of the data is in place. As of now, no data cleaning is required, so let's start with some data manipulation, analysis, and visualisation to get various insights about the data.  -    Subtask 2.1: Reduce those Digits!These numbers in the `budget` and `gross` are too big, compromising its readability. Let's convert the unit of the `budget` and `gross` columns from `$` to `million $` first.<jupyter_code># Divide the 'gross' and 'budget' columns by 1000000 to convert '$' to 'million $'
movies['Gross'] = movies['Gross'] / 1000000 #Diving the Gross column by 1000000 and appending the values to Gross
movies['budget'] = movies['budget'] / 1000000 #Diving the Budget column by 1000000 and appending the values to Budget
movies.head() #Checking the top 5 rows<jupyter_output><empty_output><jupyter_text>-    Subtask 2.2: Let's Talk Profit!    1. Create a new column called `profit` which contains the difference of the two columns: `gross` and `budget`.    2. Sort the dataframe using the `profit` column as reference.    3. Extract the top ten profiting movies in descending order and store them in a new dataframe - `top10`.    4. Plot a scatter or a joint plot between the columns `budget` and `profit` and write a few words on what you observed.    5. Extract the movies with a negative profit and store them in a new dataframe - `neg_profit`<jupyter_code># Create the new column named 'profit' by subtracting the 'budget' column from the 'gross' column
movies['profit'] = movies['Gross'] - movies['budget'] #Profit = Gross - budget
movies.head() # print top 5 records
# Sort the dataframe with the 'profit' column as reference using the 'sort_values' function. Make sure to set the argument
#'ascending' to 'False'
movies = movies.sort_values(by='profit', ascending=False)
movies.head()
# Get the top 10 profitable movies by using position based indexing. Specify the rows till 10 (0-9)

movies.sort_values(by='profit',ascending=False).head(10) #Sorting by profit and descending is True
movies.reset_index(drop=True,inplace=True) # resetting the index column so that the sequence is maintained
movies.head()
#Plot profit vs budget
sns.jointplot('budget' , 'profit', movies) #Joint Plot for plotting Budget vs Profit for the movies DF
plt.show() #Display the graph<jupyter_output><empty_output><jupyter_text>The dataset contains the 100 best performing movies from the year 2010 to 2016. However scatter plot tells a different story. You can notice that there are some movies with negative profit. Although good movies do incur losses, but there appear to be quite a few movie with losses. What can be the reason behind this? Lets have a closer look at this by finding the movies with negative profit.<jupyter_code>#Find the movies with negative profit
neg_profit = movies[(movies['profit']<0)] #Creating a new DF neg_profit by extracting profit lesser than 0
neg_profit.reset_index(drop=True,inplace=True) #Resetting the index for neg_profit DF
neg_profit<jupyter_output><empty_output><jupyter_text>**`Checkpoint 1:`** Can you spot the movie `Tangled` in the dataset? You may be aware of the movie 'Tangled'. Although its one of the highest grossing movies of all time, it has negative profit as per this result. If you cross check the gross values of this movie (link: https://www.imdb.com/title/tt0398286/), you can see that the gross in the dataset accounts only for the domestic gross and not the worldwide gross. This is true for may other movies also in the list. -  Subtask 2.3: The General Audience and the CriticsYou might have noticed the column `MetaCritic` in this dataset. This is a very popular website where an average score is determined through the scores given by the top-rated critics. Second, you also have another column `IMDb_rating` which tells you the IMDb rating of a movie. This rating is determined by taking the average of hundred-thousands of ratings from the general audience. As a part of this subtask, you are required to find out the highest rated movies which have been liked by critics and audiences alike.1. Firstly you will notice that the `MetaCritic` score is on a scale of `100` whereas the `IMDb_rating` is on a scale of 10. First convert the `MetaCritic` column to a scale of 10.2. Now, to find out the movies which have been liked by both critics and audiences alike and also have a high rating overall, you need to -    - Create a new column `Avg_rating` which will have the average of the `MetaCritic` and `Rating` columns    - Retain only the movies in which the absolute difference(using abs() function) between the `IMDb_rating` and `Metacritic` columns is less than 0.5. Refer to this link to know how abs() funtion works - https://www.geeksforgeeks.org/abs-in-python/ .    - Sort these values in a descending order of `Avg_rating` and retain only the movies with a rating equal to higher than `8` and store these movies in a new dataframe `UniversalAcclaim`.<jupyter_code># Change the scale of MetaCritic

movies['MetaCritic'] = movies['MetaCritic'] / 10 # Divide the MetaCritic column by 10 and store it back to MetaCritic
# Find the average ratings

movies['Avg_rating'] = (movies['MetaCritic'] + movies['IMDb_rating']) / 2 
#For calculating Avg_rating we are dividing (MetaCritic + IMDB_rating) /2 
#Sort in descending order of average rating

movies.sort_values(by='Avg_rating',ascending=False) #Sorting DF based on Avg_rating in descending order
# Find the movies with metacritic-rating < 0.5 and also with the average rating of >=8
UniversalAcclaim = movies.loc[(abs((movies['IMDb_rating'] - movies['MetaCritic']) < 0.5)) & (movies['Avg_rating'] >= 8)]
UniversalAcclaim
#Retaining the movies using absolute diff of Rating & Metacritic less than 0.5 and Avg_rating >= 8 & storing in UniversalAcclaim DF<jupyter_output><empty_output><jupyter_text>**`Checkpoint 2:`** Can you spot a `Star Wars` movie in your final dataset? -  Subtask 2.4: Find the Most Popular Trios - IYou're a producer looking to make a blockbuster movie. There will primarily be three lead roles in your movie and you wish to cast the most popular actors for it. Now, since you don't want to take a risk, you will cast a trio which has already acted in together in a movie before. The metric that you've chosen to check the popularity is the Facebook likes of each of these actors.The dataframe has three columns to help you out for the same, viz. `actor_1_facebook_likes`, `actor_2_facebook_likes`, and `actor_3_facebook_likes`. Your objective is to find the trios which has the most number of Facebook likes combined. That is, the sum of `actor_1_facebook_likes`, `actor_2_facebook_likes` and `actor_3_facebook_likes` should be maximum.Find out the top 5 popular trios, and output their names in a list.<jupyter_code># Write your code here
#Adding a column popularity that sums the facebook likes of all three actors
movies['Popularity'] = movies.loc[:,['actor_1_facebook_likes',
                                    'actor_2_facebook_likes',
                                    'actor_3_facebook_likes']].sum(axis=1)
#based on the popularity fetching the top 5 records
popular_actor = movies.sort_values(by='Popularity',ignore_index=True, ascending=False).loc[0:4,:]
popular_actor
# Displaying the list of top 5 trios
top_popular = movies.sort_values(by='Popularity',ascending=False,ignore_index=True).loc[0:4,['actor_1_name','actor_2_name','actor_3_name']].values.tolist()
top_popular<jupyter_output><empty_output><jupyter_text>-  Subtask 2.5: Find the Most Popular Trios - IIIn the previous subtask you found the popular trio based on the total number of facebook likes. Let's add a small condition to it and make sure that all three actors are popular. The condition is **none of the three actors' Facebook likes should be less than half of the other two**. For example, the following is a valid combo:- actor_1_facebook_likes: 70000- actor_2_facebook_likes: 40000- actor_3_facebook_likes: 50000But the below one is not:- actor_1_facebook_likes: 70000- actor_2_facebook_likes: 40000- actor_3_facebook_likes: 30000since in this case, `actor_3_facebook_likes` is 30000, which is less than half of `actor_1_facebook_likes`.Having this condition ensures that you aren't getting any unpopular actor in your trio (since the total likes calculated in the previous question doesn't tell anything about the individual popularities of each actor in the trio.).You can do a manual inspection of the top 5 popular trios you have found in the previous subtask and check how many of those trios satisfy this condition. Also, which is the most popular trio after applying the condition above? **Write your answers below.**- **`No. of trios that satisfy the above condition:`**- **`Most popular trio after applying the condition:`** **`Optional:`** Even though you are finding this out by a natural inspection of the dataframe, can you also achieve this through some *if-else* statements to incorporate this. You can try this out on your own time after you are done with the assignment.<jupyter_code># Your answer here (optional)
indi_popularity = movies[~(
                (((movies['actor_1_facebook_likes'] < movies['actor_2_facebook_likes']/2) |
                 (movies['actor_1_facebook_likes'] < movies['actor_3_facebook_likes']/2)) == True)
               |(((movies['actor_2_facebook_likes'] < movies['actor_1_facebook_likes']/2) |
                 (movies['actor_2_facebook_likes'] < movies['actor_3_facebook_likes']/2)) == True)
               |(((movies['actor_3_facebook_likes'] < movies['actor_1_facebook_likes']/2) |
                 (movies['actor_3_facebook_likes'] < movies['actor_2_facebook_likes']/2)) == True)
)]
pop_actors = popular_actor[popular_actor['Title'].isin(indi_popularity['Title'])]
pop_actors
final_popular_trio = pop_actors.sort_values(by='Popularity',ascending=False,ignore_index=True).loc[0:5,['actor_1_name','actor_2_name','actor_3_name']].values.tolist()
final_popular_trio<jupyter_output><empty_output><jupyter_text>-  Subtask 2.6: Runtime AnalysisThere is a column named `Runtime` in the dataframe which primarily shows the length of the movie. It might be intersting to see how this variable this distributed. Plot a `histogram` or `distplot` of seaborn to find the `Runtime` range most of the movies fall into.<jupyter_code># Runtime histogram/density plot
sns.set_style('whitegrid') #setting whitegrid as the style 
sns.distplot(movies['Runtime']) #drawing a distplot for finding the range for Runtime from movies DF
plt.show()<jupyter_output><empty_output><jupyter_text>**`Checkpoint 3:`** Most of the movies appear to be sharply 2 hour-long. -  Subtask 2.7: R-Rated MoviesAlthough R rated movies are restricted movies for the under 18 age group, still there are vote counts from that age group. Among all the R rated movies that have been voted by the under-18 age group, find the top 10 movies that have the highest number of votes i.e.`CVotesU18` from the `movies` dataframe. Store these in a dataframe named `PopularR`.<jupyter_code># Write your code here

PopularR = movies[['Title','CVotesU18','content_rating']]
PopularR = PopularR.loc[(PopularR.content_rating == 'R')].sort_values(by='CVotesU18',ascending=False)
PopularR.head(10)

# Creating Popular DF by adding Title,CVotesU18,content_rating columns
# Filter the content_rating by 'R' using loc and sorting the values based on CVotesU18
#Display the top 10 popular R rated movies<jupyter_output><empty_output><jupyter_text>**`Checkpoint 4:`** Are these kids watching `Deadpool` a lot?    Task 3 : Demographic analysisIf you take a look at the last columns in the dataframe, most of these are related to demographics of the voters (in the last subtask, i.e., 2.8, you made use one of these columns - CVotesU18). We also have three genre columns indicating the genres of a particular movie. We will extensively use these columns for the third and the final stage of our assignment wherein we will analyse the voters across all demographics and also see how these vary across various genres. So without further ado, let's get started with `demographic analysis`. -    Subtask 3.1 Combine the Dataframe by GenresThere are 3 columns in the dataframe - `genre_1`, `genre_2`, and `genre_3`. As a part of this subtask, you need to aggregate a few values over these 3 columns. 1. First create a new dataframe `df_by_genre` that contains `genre_1`, `genre_2`, and `genre_3` and all the columns related to **CVotes/Votes** from the `movies` data frame. There are 47 columns to be extracted in total.2. Now, Add a column called `cnt` to the dataframe `df_by_genre` and initialize it to one. You will realise the use of this column by the end of this subtask.3. First group the dataframe `df_by_genre` by `genre_1` and find the sum of all the numeric columns such as `cnt`, columns related to CVotes and Votes columns and store it in a dataframe `df_by_g1`.4. Perform the same operation for `genre_2` and `genre_3` and store it dataframes `df_by_g2` and `df_by_g3` respectively. 5. Now that you have 3 dataframes performed by grouping over `genre_1`, `genre_2`, and `genre_3` separately, it's time to combine them. For this, add the three dataframes and store it in a new dataframe `df_add`, so that the corresponding values of Votes/CVotes get added for each genre.There is a function called `add()` in pandas which lets you do this. You can refer to this link to see how this function works. https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.DataFrame.add.html6. The column `cnt` on aggregation has basically kept the track of the number of occurences of each genre.Subset the genres that have atleast 10 movies into a new dataframe `genre_top10` based on the `cnt` column value.7. Now, take the mean of all the numeric columns by dividing them with the column value `cnt` and store it back to the same dataframe. We will be using this dataframe for further analysis in this task unless it is explicitly mentioned to use the dataframe `movies`.8. Since the number of votes can't be a fraction, type cast all the CVotes related columns to integers. Also, round off all the Votes related columns upto two digits after the decimal point.<jupyter_code># Create the dataframe df_by_genre

df_by_genre = pd.concat([movies.loc[:,['genre_1','genre_2','genre_3']], movies.iloc[:,16:-4]],join='outer', axis =1)
df_by_genre

# Creating a df_by_genre DF by aquiring the required columns (genre 1,2,3 and all CVotes & Votes columns that sums upto 47)
# print the df_by_genre
# Create a column cnt and initialize it to 1

df_by_genre['cnt'] = 1 # Creating a column 'cnt' and assigning a default value of 1
df_by_genre # print the DF df_by_genre
# Group the movies by individual genres

df_by_genre.groupby('genre_1').sum() #Grouping Genre 1 
df_by_genre.groupby('genre_2').sum() #Grouping Genre 2
df_by_genre.groupby('genre_3').sum() #Grouping Genre 3
# Add the grouped data frames and store it in a new data frame
df_by_g1 = df_by_genre.groupby('genre_1').sum() #Creating a new DF df_by_g1 based on genre_1
df_by_g2 = df_by_genre.groupby('genre_2').sum() #Creating a new DF df_by_g2 based on genre_2
df_by_g3 = df_by_genre.groupby('genre_3').sum() #Creating a new DF df_by_g3 based on genre_3

final_genre = df_by_g1.add(df_by_g2,fill_value=0)
df_add = final_genre.add(df_by_g3,fill_value=0)
df_add = df_add.sort_values(by='cnt',ascending=False)
df_add

# Creating final_genre DF to combine df_by_g1 & df_by_g2
# Creating df_add DF to combile final_genre & df_by_g3
# print the DF df_add
# Extract genres with atleast 10 occurences

genre_top10 = df_add[df_add['cnt'] >= 10] # other possible solution for getting the same result: genre_top10 = df_add.iloc[:10]
genre_top10

# Take the mean for every column by dividing with cnt 

genre_top10 = genre_top10.iloc[:,:-1].div(genre_top10.cnt, axis = 0).join(genre_top10.cnt)
genre_top10

# compute the mean by dividing Cvotes& Votes by cnt and display the results
# Rounding off the columns of Votes to two decimals

votes = genre_top10.iloc[:,27:].apply(lambda x: pd.Series.round(x,2))
votes
# Converting CVotes to int type

cvotes = genre_top10.iloc[:,:27].round().astype(int)
cvotes
genre_votes = pd.concat([cvotes, votes], axis=1,ignore_index=False)
genre_votes

# We have created 2 DF's cvotes and votes to perform individual actions 
# convert cvotes to int
# convert votes to 2 decimal places
# finally concate both cvotes and votes based on index and display the result<jupyter_output><empty_output><jupyter_text>If you take a look at the final dataframe that you have gotten, you will see that you now have the complete information about all the demographic (Votes- and CVotes-related) columns across the top 10 genres. We can use this dataset to extract exciting insights about the voters! -    Subtask 3.2: Genre Counts!Now let's derive some insights from this data frame. Make a bar chart plotting different genres vs cnt using seaborn.<jupyter_code># Countplot for genres

plt.figure(figsize=[10,6]) # configuring the size of the bar chart
genre_counts = sns.barplot(data=genre_top10, x = genre_top10.index, y = genre_top10.cnt) 
genre_counts.set(xlabel="Genre", ylabel = "Count", title = "Genre Counts")
plt.show()

# creating a barplot plotting genres vs count 
# setting up the labels for x & y
# Set the title as Genre Counts and display the graph<jupyter_output><empty_output><jupyter_text>**`Checkpoint 5:`** Is the bar for `Drama` the tallest? -    Subtask 3.3: Gender and GenreIf you have closely looked at the Votes- and CVotes-related columns, you might have noticed the suffixes `F` and `M` indicating Female and Male. Since we have the vote counts for both males and females, across various age groups, let's now see how the popularity of genres vary between the two genders in the dataframe. 1. Make the first heatmap to see how the average number of votes of males is varying across the genres. Use seaborn heatmap for this analysis. The X-axis should contain the four age-groups for males, i.e., `CVotesU18M`,`CVotes1829M`, `CVotes3044M`, and `CVotes45AM`. The Y-axis will have the genres and the annotation in the heatmap tell the average number of votes for that age-male group. 2. Make the second heatmap to see how the average number of votes of females is varying across the genres. Use seaborn heatmap for this analysis. The X-axis should contain the four age-groups for females, i.e., `CVotesU18F`,`CVotes1829F`, `CVotes3044F`, and `CVotes45AF`. The Y-axis will have the genres and the annotation in the heatmap tell the average number of votes for that age-female group. 3. Make sure that you plot these heatmaps side by side using `subplots` so that you can easily compare the two genders and derive insights.4. Write your any three inferences from this plot. You can make use of the previous bar plot also here for better insights.Refer to this link- https://seaborn.pydata.org/generated/seaborn.heatmap.html. You might have to plot something similar to the fifth chart in this page (You have to plot two such heatmaps side by side).5. Repeat subtasks 1 to 4, but now instead of taking the CVotes-related columns, you need to do the same process for the Votes-related columns. These heatmaps will show you how the two genders have rated movies across various genres.You might need the below link for formatting your heatmap.https://stackoverflow.com/questions/56942670/matplotlib-seaborn-first-and-last-row-cut-in-half-of-heatmap-plot-  Note : Use `genre_top10` dataframe for this subtask<jupyter_code># 1st set of heat maps for CVotes-related columns 
male_cvote = genre_top10.groupby(genre_top10.index)['CVotesU18M','CVotes1829M','CVotes3044M','CVotes45AM'].mean().astype(int)
female_cvote = genre_top10.groupby(genre_top10.index)['CVotesU18F','CVotes1829F','CVotes3044F','CVotes45AF'].mean().astype(int)

fig = plt.figure(num=None, figsize=(10, 8), dpi=80, facecolor='w', edgecolor='k')
fig,(ax1,ax2,axcb) = plt.subplots(1,3, gridspec_kw={'width_ratios':[1,1,0.08]})
ax1.get_shared_y_axes().join(ax1,ax2)
mcvote = sns.heatmap(male_cvote,cmap='Blues', annot=True, fmt='g',cbar=False, ax=ax1)
mcvote.set_ylabel('Genre', fontsize=10)
mcvote.set_xlabel('Male Age Group', fontsize=10)
fcvote = sns.heatmap(female_cvote,cmap='Blues', annot=True, fmt='g',cbar_ax=axcb, ax=ax2)
fcvote.set_xlabel('Female Age Group', fontsize=10)
fcvote.set_yticks([ ])

plt.show()<jupyter_output><empty_output><jupyter_text>**`Inferences:`** A few inferences that can be seen from the heatmap above is that males have voted more than females, and Sci-Fi appears to be most popular among the 18-29 age group irrespective of their gender. What more can you infer from the two heatmaps that you have plotted? Write your three inferences/observations below:- Inference 1: Ages 18-44 across gender has voted the most for all genre- Inference 2: On an average females 18-44 voted less for movies of Action, Adventure, Animation, Comedy, Romance and Thriller genre when compared to males- Inference 3: Romance is the least voted by Male irrespective of their age compared to female, but if only male gender is considered, they voted least for romance<jupyter_code># 2nd set of heat maps for Votes-related columns
male_vote = round(genre_top10.groupby(genre_top10.index)['VotesU18M','Votes1829M','Votes3044M','Votes45AM'].mean(),2)
female_vote = round(genre_top10.groupby(genre_top10.index)['VotesU18F','Votes1829F','Votes3044F','Votes45AF'].mean(),2)

fig = plt.figure(num=None, figsize=(10, 8), dpi=80, facecolor='w', edgecolor='k')
fig,(ax1,ax2,axcb) = plt.subplots(1,3, gridspec_kw={'width_ratios':[1,1,0.08]})
ax1.get_shared_y_axes().join(ax1,ax2)
mcvote = sns.heatmap(male_vote,cmap='coolwarm', annot=True, fmt='g',cbar=False, ax=ax1)
mcvote.set_ylabel('Genre', fontsize=10)
mcvote.set_xlabel('Male Age Group', fontsize=10)
fcvote = sns.heatmap(female_vote,cmap='coolwarm', annot=True, fmt='g',cbar_ax=axcb, ax=ax2)
fcvote.set_xlabel('Female Age Group', fontsize=10)
fcvote.set_yticks([ ])

plt.show()<jupyter_output><empty_output><jupyter_text>**`Inferences:`** Sci-Fi appears to be the highest rated genre in the age group of U18 for both males and females. Also, females in this age group have rated it a bit higher than the males in the same age group. What more can you infer from the two heatmaps that you have plotted? Write your three inferences/observations below:- Inference 1: It is interesting to see that the romance movies are watched less or voted less by males when compared to females especially for U18- Inference 2: Both genders of age group 30 and above the minimum rating ranges from 7.5 - 7.98 and has not reached 8- Inference 3: Comedy genre seems to be liked by both genres across age groups with a minor variance -    Subtask 3.4: US vs non-US Cross AnalysisThe dataset contains both the US and non-US movies. Let's analyse how both the US and the non-US voters have responded to the US and the non-US movies.1. Create a column `IFUS` in the dataframe `movies`. The column `IFUS` should contain the value "USA" if the `Country` of the movie is "USA". For all other countries other than the USA, `IFUS` should contain the value `non-USA`.2. Now make a boxplot that shows how the number of votes from the US people i.e. `CVotesUS` is varying for the US and non-US movies. Make use of the column `IFUS` to make this plot. Similarly, make another subplot that shows how non US voters have voted for the US and non-US movies by plotting `CVotesnUS` for both the US and non-US movies. Write any of your two inferences/observations from these plots.3. Again do a similar analysis but with the ratings. Make a boxplot that shows how the ratings from the US people i.e. `VotesUS` is varying for the US and non-US movies. Similarly, make another subplot that shows how `VotesnUS` is varying for the US and non-US movies. Write any of your two inferences/observations from these plots.Note : Use `movies` dataframe for this subtask. Make use of this documention to format your boxplot - https://seaborn.pydata.org/generated/seaborn.boxplot.html<jupyter_code># Creating IFUS column

#below using lambda condition appended to column ['IFUS'] if the movie is from USA or non-USA 
movies['IFUS'] = movies['Country'].apply(lambda x:'USA' if x== 'USA' else 'non-USA') 
movies # listing the movies DF with the newly appended column
# Box plot - 1: CVotesUS(y) vs IFUS(x)

plt.figure(figsize=[10,10]) #Sizing the boxplot
fig, axes = plt.subplots(nrows=1, ncols=2) #defining rows & cols for subplot

#boxplot for cvotesus
cvotesus = sns.boxplot(data=movies, x=movies.IFUS, y=movies.CVotesUS, orient ='v',ax=axes[0]) # Generating boxplot - IFUS , CVotesUS
cvotesus.axes.set_title('Dist. of votes by USA voters', fontsize = 10)# Setting the title for the box plot
cvotesus.set_ylabel('CVotesUS', fontsize =10)
cvotesus.set_xlabel('IFUS', fontsize =10)

#boxplot for cvotesnus
cvotesnus = sns.boxplot(data=movies, x=movies.IFUS, y=movies.CVotesnUS, orient ='v',ax=axes[1]) # Generating boxplot - IFUS , CVotesnUS
cvotesnus.axes.set_title('Dist. of votes by non-USA voters', fontsize = 10)# Setting the title for the box plot
cvotesnus.set_ylabel('CVotesnUS', fontsize =10)
cvotesnus.set_xlabel('IFUS', fontsize =10)

plt.tight_layout() #for non-overlapping of box plot<jupyter_output><empty_output><jupyter_text>**`Inferences:`** Write your two inferences/observations below:- Inference 1: From both the plots we can see that there are some outliers for USA movies- Inference 2: We can observe non-USA movies the number of votes is uniformly distributed compared to USA movies<jupyter_code># Box plot - 2: VotesUS(y) vs IFUS(x)

plt.figure(figsize=[10,10]) #Sizing the boxplot
fig, axes = plt.subplots(nrows=1, ncols=2) #defining rows & cols for subplot

#boxplot for cvotesus
votesus = sns.boxplot(data=movies, x=movies.IFUS, y=movies.VotesUS, orient ='v',ax=axes[0]) # Generating boxplot - IFUS , VotesUS
votesus.axes.set_title('Dist. of votes by USA voters', fontsize = 10)# Setting the title for the box plot
votesus.set_ylabel('VotesUS', fontsize =10)
votesus.set_xlabel('IFUS', fontsize =10)

#boxplot for cvotesnus
votesnus = sns.boxplot(data=movies, x=movies.IFUS, y=movies.VotesnUS, orient ='v',ax=axes[1]) # Generating boxplot - IFUS , VotesnUS
votesnus.axes.set_title('Dist. of votes by non-USA voters', fontsize = 10)# Setting the title for the box plot
votesnus.set_ylabel('VotesnUS', fontsize =10)
votesnus.set_xlabel('IFUS', fontsize =10)

plt.tight_layout() #for non-overlapping of box plot<jupyter_output><empty_output><jupyter_text>**`Inferences:`** Write your two inferences/observations below:- Inference 1: From both the plots we can see that there are some outliers for USA movies- Inference 2: On average we can see the median rating is higher (around 7.9 to 8) from USA people compared to that from non- USA people -    Subtask 3.5:  Top 1000 Voters Vs GenresYou might have also observed the column `CVotes1000`. This column represents the top 1000 voters on IMDb and gives the count for the number of these voters who have voted for a particular movie. Let's see how these top 1000 voters have voted across the genres. 1. Sort the dataframe genre_top10 based on the value of `CVotes1000`in a descending order.2. Make a seaborn barplot for `genre` vs `CVotes1000`.3. Write your inferences. You can also try to relate it with the heatmaps you did in the previous subtasks.<jupyter_code># Sorting by CVotes1000

genre_top10 = genre_top10[['CVotes1000']].sort_values(by='CVotes1000',ascending=False)
# Bar plot
plt.figure(figsize=[10,5])
sns.barplot(data=genre_top10,x=genre_top10.index,y='CVotes1000')
plt.title('Top 1000 voters vs Genre', fontsize = 25)
plt.xlabel('Movie Genre', fontsize = 15)
plt.ylabel('CVotes1000', fontsize = 15)
plt.show()<jupyter_output><empty_output>