Professional Documents
Culture Documents
Top50moviesp44091 2 2
Top50moviesp44091 2 2
[5]: df=pd.read_excel("/Users/nairirtisharma/Desktop/Top50Movies.xlsx")
[6]: df.columns
plt.figure(figsize=(10, 6))
other_description.plot(kind='bar', color=['lightgreen', 'lightcoral',␣
↪'lightblue', 'orange'])
1
[40]: df.nlargest(50, 'U.S. Box Office Receipts (Inflation Adjusted Millions $)')
plt.figure(figsize=(10, 6))
sns.scatterplot(data=df, x='Year Released', y='World Box Office Receipts␣
↪(Inflation Adjusted Millions $)',hue= 'Genre')
plt.xlabel('Year Released')
plt.ylabel('Inflation-Adjusted Worlf Box Office Receipts (Millions $)')
plt.grid(True)
plt.tight_layout()
plt.show()
#INTERPRETATION : In both 1940s and 1990-2000a the highest box office␣
↪collecection have been for th Genre "Drama" ,
2
#Box office collection have been increasing for all Genre of movies in the␣
↪World more so the "Genre drama has not been prevalent after 1970-1980 .
[15]: df.nlargest(50, 'U.S. Box Office Receipts (Inflation Adjusted Millions $)')
plt.figure(figsize=(10, 6))
sns.scatterplot(data=df, x='Year Released', y='U.S. Box Office Receipts␣
↪(Inflation Adjusted Millions $)',hue= 'Genre')
plt.xlabel('Year Released')
plt.ylabel('Inflation-Adjusted U.S. Box Office Receipts (Millions $)')
plt.grid(True)
plt.tight_layout()
plt.show()
import warnings
warnings.filterwarnings("ignore")
3
#INTERPRETATION: In the US the Box - office collection has been decreasing ,␣
↪with less movies from the 'Genre' Drama and more movies from 'Genre' Scifi␣
↪Fantasy
4
[55]: import plotly.express as px
5
#for PG rated movies with reasonable increase in budget the collection has␣
↪increased
#Even with more budget the collection remaind the same for UR rated movies
#With more budget the collection decreased for G rated movies both for US and␣
↪WORLD
[122]: px.scatter(df, x="Budget (Inflation Adjusted Millions $)", y="U.S. Box Office␣
↪Receipts (Non-Inflation Adjusted Millions $)",
6
[56]: df=df.dropna(subset=['U.S. Box Office Receipts (Inflation Adjusted Millions␣
↪$)'])
percent_frequency_distribution = (frequency_distribution /␣
↪frequency_distribution.sum()) * 100
plt.figure(figsize=(10, 6))
plt.hist(df['U.S. Box Office Receipts (Inflation Adjusted Millions $)'],␣
↪bins=bin_edges, edgecolor='black', alpha=0.7)
7
plt.grid(True)
plt.show()
print("Frequency Distribution:")
print(frequency_distribution)
print()
Frequency Distribution:
U.S. Box Office Receipts (Inflation Adjusted Millions $)
(0, 100] 0
(100, 200] 0
(200, 300] 0
(300, 400] 0
(400, 500] 1
(500, 600] 14
(600, 700] 6
(700, 800] 5
(800, 900] 4
(900, 1000] 1
(1000, 1100] 3
8
(1100, 1200] 0
(1200, 1300] 0
(1300, 1400] 0
(1400, 1500] 1
(1500, 1600] 0
(1600, 1700] 1
Name: count, dtype: int64
print("Cross-tabulation for movie genre and rating for the top 50 movies:")
print(pivot_top_50)
print()
9
print("Cross-tabulation for movie genre and rating for movies released after␣
↪1980:")
print(pivot_after_1980)
print()
↪aggfunc='mean')
print(pivot_avg_receipts)
#
Cross-tabulation for movie genre and rating for the top 50 movies:
Rating G PG PG-13 R UR
Genre
Action 1 2 3 0 0
Animated 5 1 0 0 0
Comedy 0 1 0 0 0
Drama 4 2 3 1 2
Horror 0 0 0 1 0
SciFi/Fantasy 0 5 5 0 0
Cross-tabulation for movie genre and rating for movies released after 1980:
Rating G PG PG-13
Genre
Action 0 1 3
Animated 1 1 0
Drama 0 0 2
SciFi/Fantasy 0 4 5
Average inflation-adjusted U.S. box office receipts for each genre-rating pair:
Rating G PG PG-13 R UR
Genre
Action 506.600 856.35 664.100000 NaN NaN
Animated 665.140 557.40 NaN NaN NaN
Comedy NaN 561.90 NaN NaN NaN
Drama 1016.175 615.10 895.766667 622.8 519.85
Horror NaN NaN NaN 808.7 NaN
SciFi/Fantasy NaN 834.58 561.860000 NaN NaN
[ ]: #Cross-tabulation for movie genre and rating for the top 50 movies:
#This table shows the count of movies for each combination of genre and rating␣
↪among the top 50 movies.
#Insights:
10
#The most represented genre-rating pairs are Drama-PG-13 and SciFi/Fantasy-PG,␣
↪each appearing 5 times.Horror movies are represented by only one movie with␣
#Cross-tabulation for movie genre and rating for movies released after 1980:
#This table presents the count of movies for each genre-rating combination␣
↪among movies released after 1980.
#Insights:PG-13 rated SciFi/Fantasy and Drama movies are the most common, each␣
↪appearing in 5 movies.Action movies with a PG-13 rating follow closely,␣
↪appearing in 3 movies.
#Average inflation-adjusted U.S. box office receipts for each genre-rating pair:
↪This table displays the average box office receipts for each genre-rating␣
↪combination.
#Insights: #Drama movies with a G rating have the highest average box office␣
↪receipts at $1016.175 million.
#Comedy movies with a PG rating have an average box office receipts of $561.90␣
↪million.
#Action movies with a PG rating have an average box office receipts of $856.35␣
↪million.
#SciFi/Fantasy movies with a PG rating also have a high average box office␣
↪receipts of $834.58 million.
11