-
Notifications
You must be signed in to change notification settings - Fork 0
/
Imdb_Data_Analysis.py
66 lines (55 loc) · 2.11 KB
/
Imdb_Data_Analysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Python program to plot data
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# reading the csv file
df = pd.read_csv('/home/nadia/PycharmProjects/Web_Scraping/IMDb_data_2020.csv')
# counting the rates in intervals
ratings = sum(i > 8.0 for i in df['imdb']), \
sum(6.0 < i < 8.0 for i in df['imdb']), \
sum(5.0 < i < 6.0 for i in df['imdb']), \
sum(3.0 < i < 5.0 for i in df['imdb']), \
sum(i < 3.0 for i in df['imdb'])
meta_score = sum(i > 90.0 for i in df['metascore']), \
sum(80 < i < 90.0 for i in df['metascore']), \
sum(60.0 < i < 80.0 for i in df['metascore']), \
sum(50.0 < i < 60.0 for i in df['metascore']), \
sum(30.0 < i < 50.0 for i in df['metascore']), \
sum(i < 30.0 for i in df['metascore'])
print(meta_score)
activities = ['rate > 8.0', '6.0 < rate < 8.0', '5.0 < rate < 6.0', '3.0 < rate < 5.0', 'rate < 3.0']
labels = ['meta_score > 90', '80 < meta_score < 90', '60 < meta_score < 80', '50 < meta_score < 60',
'30 < meta_score < 50', 'meta_score < 30']
# color for each label
colors_rates = ['r', 'y', 'g', 'b', 'c']
# plotting the pie chart
plt.pie(ratings, colors=colors_rates,
startangle=90, shadow=True, explode=(0, 0, 0, 0, 0),
radius=1.2, autopct='%1.0f%%')
# plotting legend
plt.legend(activities)
plt.title('2020\'s movies and shows imdb rates')
# showing the plot
plt.show()
colors_score = ['red', 'orange', 'green', 'purple', 'cyan', 'brown']
# plotting the pie chart
plt.pie(meta_score, colors=colors_score,
startangle=90, shadow=True, explode=(0, 0, 0, 0, 0, 0),
radius=1.2, autopct='%1.0f%%')
# plotting legend
plt.legend(labels)
plt.title('2020\'s movies and shows metascores')
# showing the plot
plt.show()
left = [1, 2, 3, 4, 5]
# plotting a bar chart
plt.bar(left, ratings, tick_label=activities,
width=0.8, color=['red', 'green'])
# naming the x-axis
plt.xlabel('Rates')
# naming the y-axis
plt.ylabel('Number of movies and shows')
# plot title
plt.title('2020\'s movies and shows imdb rates')
# function to show the plot
plt.show()