Spaces:
Sleeping
Sleeping
kaw101010
commited on
Commit
·
694e4f6
1
Parent(s):
119d7e0
Upload scripts
Browse files- Data.py +17 -0
- LICENSE +201 -0
- README.md +2 -13
- __pycache__/conf.cpython-310.pyc +0 -0
- __pycache__/conf.cpython-38.pyc +0 -0
- cast_retrieval.py +27 -0
- conf.py +3 -0
- data_retrieval.py +81 -0
- movie_cast.csv +0 -0
- movies2.csv +0 -0
- pages/Chart_Visualization.py +63 -0
- pages/Popular_Movies.py +20 -0
- pages/View_Specific_Data.py +51 -0
- requirements.txt +3 -0
Data.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
st.set_page_config(
|
5 |
+
page_title="Movie Explorer",
|
6 |
+
layout="wide",
|
7 |
+
initial_sidebar_state="expanded",
|
8 |
+
)
|
9 |
+
|
10 |
+
st.markdown("<h1 style='text-align: center;'>Movie Analysis</h1>", unsafe_allow_html=True)
|
11 |
+
movies_df = pd.read_csv('movies2.csv',lineterminator='\n')
|
12 |
+
movies_df = movies_df.drop(columns=movies_df.columns[0])
|
13 |
+
movies_df = movies_df[movies_df['Release Date'] < "2022-01-01"]
|
14 |
+
st.write(movies_df)
|
15 |
+
st.caption("Data Source: TMDB")
|
16 |
+
cast_df = pd.read_csv('movie_cast.csv')
|
17 |
+
|
LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright [yyyy] [name of copyright owner]
|
190 |
+
|
191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
+
you may not use this file except in compliance with the License.
|
193 |
+
You may obtain a copy of the License at
|
194 |
+
|
195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
+
|
197 |
+
Unless required by applicable law or agreed to in writing, software
|
198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
+
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
README.md
CHANGED
@@ -1,13 +1,2 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
emoji: 📉
|
4 |
-
colorFrom: purple
|
5 |
-
colorTo: blue
|
6 |
-
sdk: streamlit
|
7 |
-
sdk_version: 1.21.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
license: apache-2.0
|
11 |
-
---
|
12 |
-
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
# Movie-Analysis
|
2 |
+
Analysis of Popular movies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__pycache__/conf.cpython-310.pyc
ADDED
Binary file (190 Bytes). View file
|
|
__pycache__/conf.cpython-38.pyc
ADDED
Binary file (176 Bytes). View file
|
|
cast_retrieval.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests as req
|
2 |
+
import pandas as pd
|
3 |
+
from Data import movies_df
|
4 |
+
from conf import api_key
|
5 |
+
|
6 |
+
ses = req.session()
|
7 |
+
|
8 |
+
crew = []
|
9 |
+
ids = []
|
10 |
+
for movie_id in movies_df['Id']:
|
11 |
+
ids.append(movie_id)
|
12 |
+
cast_api = "https://api.themoviedb.org/3/movie/" + str(movie_id) + '/credits?api_key=' + api_key + '&language=en-US'
|
13 |
+
c = ses.get(cast_api)
|
14 |
+
casts = c.json()
|
15 |
+
movie_cast = []
|
16 |
+
try:
|
17 |
+
count = 0
|
18 |
+
for i in casts["cast"]:
|
19 |
+
if count < 5:
|
20 |
+
movie_cast.append(i['name'])
|
21 |
+
count += 1
|
22 |
+
crew.append(movie_cast)
|
23 |
+
except:
|
24 |
+
crew.append("N/A")
|
25 |
+
cast_df = pd.DataFrame({"Movie Id":ids, "Cast": crew})
|
26 |
+
cast_df.to_csv("movie_cast.csv")
|
27 |
+
|
conf.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Used .gitignore to hide api key
|
2 |
+
|
3 |
+
api_key = 'fdb378a1a8e6a38bc30049ee94f2b87a'
|
data_retrieval.py
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Retrieve data from TMDB using API
|
2 |
+
|
3 |
+
import requests as req
|
4 |
+
import pandas as pd
|
5 |
+
from conf import api_key
|
6 |
+
|
7 |
+
ses = req.session()
|
8 |
+
|
9 |
+
genre_api = 'https://api.themoviedb.org/3/genre/movie/list?api_key=' + api_key + '&language=en-US&page=1'
|
10 |
+
|
11 |
+
g = ses.get(genre_api)
|
12 |
+
genres = g.json()
|
13 |
+
g_id = []
|
14 |
+
g_name = []
|
15 |
+
for i in genres['genres']:
|
16 |
+
g_id.append(i['id'])
|
17 |
+
g_name.append(i['name'])
|
18 |
+
|
19 |
+
ids = []
|
20 |
+
titles = []
|
21 |
+
desc = []
|
22 |
+
pop = []
|
23 |
+
rate = []
|
24 |
+
date = []
|
25 |
+
resp = []
|
26 |
+
genre = []
|
27 |
+
rev = []
|
28 |
+
|
29 |
+
|
30 |
+
for k in range(1,500): # Returns 7387 movies as data
|
31 |
+
api = 'https://api.themoviedb.org/3/movie/popular?api_key=' + api_key + '&language=en-US&page='+str(k)
|
32 |
+
data = ses.get(api)
|
33 |
+
j = data.json()
|
34 |
+
for i in j['results']:
|
35 |
+
if i['original_language'] == 'en':
|
36 |
+
try:
|
37 |
+
ids.append(i['id'])
|
38 |
+
except:
|
39 |
+
ids.append(None)
|
40 |
+
try:
|
41 |
+
titles.append(i['title'])
|
42 |
+
except:
|
43 |
+
titles.append(None)
|
44 |
+
try:
|
45 |
+
desc.append(i['overview'])
|
46 |
+
except:
|
47 |
+
desc.append(None)
|
48 |
+
try:
|
49 |
+
pop.append(i['popularity'])
|
50 |
+
except:
|
51 |
+
pop.append(None)
|
52 |
+
try:
|
53 |
+
rate.append(i['vote_average'])
|
54 |
+
except:
|
55 |
+
rate.append(None)
|
56 |
+
try:
|
57 |
+
date.append(i['release_date'])
|
58 |
+
except:
|
59 |
+
date.append(None)
|
60 |
+
try:
|
61 |
+
resp.append(i['vote_count'])
|
62 |
+
except:
|
63 |
+
resp.append(None)
|
64 |
+
try:
|
65 |
+
p = []
|
66 |
+
for u in range(len(i['genre_ids'])):
|
67 |
+
if i['genre_ids'][u] in g_id:
|
68 |
+
p.append(g_name[g_id.index(i['genre_ids'][u])])
|
69 |
+
genre.append(p)
|
70 |
+
except:
|
71 |
+
genre.append(None)
|
72 |
+
try:
|
73 |
+
rev_api = 'https://api.themoviedb.org/3/movie/' + str(i['id']) + '?api_key=' + api_key + '&language=en-US'
|
74 |
+
r = ses.get(rev_api)
|
75 |
+
re = r.json()
|
76 |
+
rev.append(re['revenue'])
|
77 |
+
except:
|
78 |
+
rev.append(None)
|
79 |
+
|
80 |
+
df = pd.DataFrame({'Id':ids, 'Title':titles,'Description':desc,'Popularity':pop,'Genres':genre,'Release Date': date,'Rating':rate,'Vote Count':resp,'Revenue':rev})
|
81 |
+
df.to_csv('movies2.csv')
|
movie_cast.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
movies2.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
pages/Chart_Visualization.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from Data import movies_df
|
3 |
+
import altair as alt
|
4 |
+
import pandas as pd
|
5 |
+
|
6 |
+
ops = ['Action']
|
7 |
+
rev_action = 0
|
8 |
+
rev_adv = 0
|
9 |
+
rev_hor = 0
|
10 |
+
rev_anim = 0
|
11 |
+
rev_fant = 0
|
12 |
+
rev_crim = 0
|
13 |
+
rev_thr = 0
|
14 |
+
rev_mys = 0
|
15 |
+
rev_dr = 0
|
16 |
+
rev_comic = 0
|
17 |
+
rev_his = 0
|
18 |
+
rev_tv = 0
|
19 |
+
rev_wes = 0
|
20 |
+
rev_sci = 0
|
21 |
+
rev_rom = 0
|
22 |
+
|
23 |
+
for i in movies_df['Genres']:
|
24 |
+
if 'Action' in i:
|
25 |
+
rev_action += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
26 |
+
elif 'Adventure' in i:
|
27 |
+
rev_adv += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
28 |
+
elif 'Animation' in i:
|
29 |
+
rev_anim += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
30 |
+
elif 'Horror' in i:
|
31 |
+
rev_hor += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
32 |
+
elif 'Fantasy' in i:
|
33 |
+
rev_fant += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
34 |
+
elif 'Crime' in i:
|
35 |
+
rev_crim += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
36 |
+
elif 'Mystery' in i:
|
37 |
+
rev_mys += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
38 |
+
elif 'Comedy' in i:
|
39 |
+
rev_comic += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
40 |
+
elif 'History' in i:
|
41 |
+
rev_his += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
42 |
+
elif 'TV Show' in i:
|
43 |
+
rev_tv += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
44 |
+
elif 'Western' in i:
|
45 |
+
rev_wes += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
46 |
+
elif 'Science Fiction' in i:
|
47 |
+
rev_sci += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
48 |
+
elif 'Romance' in i:
|
49 |
+
rev_rom += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
50 |
+
elif 'Thriller' in i:
|
51 |
+
rev_thr += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
52 |
+
elif 'Drama' in i:
|
53 |
+
rev_dr += int(movies_df[movies_df['Genres'] == i]['Revenue'].tolist()[0])
|
54 |
+
# TV Shows are not included because revenue of TV Shows is 0 or unknown.
|
55 |
+
revenue = [rev_dr,rev_action,rev_adv,rev_anim,rev_wes,rev_mys,rev_crim,rev_his,rev_comic,rev_fant,rev_rom,rev_sci,rev_thr,rev_hor]
|
56 |
+
genres = ['Drama','Action','Adventure','Animation','Western','Mystery','Crime','History','Comedy','Fantasy','Romance','Science Fiction','Thriller','Horror']
|
57 |
+
gen_rev = pd.DataFrame({'Genres':genres, 'Revenue':revenue})
|
58 |
+
|
59 |
+
st.write('## Comparison of Revenue for each Movie Genre')
|
60 |
+
st.altair_chart(alt.Chart(gen_rev).mark_bar().encode(x = alt.X('Genres', title = "Movie Genre", axis= alt.Axis(labelAngle = -45)), y = alt.Y('Revenue', title = 'Revenue (in USD)')).properties(width = 800,height = 500).configure_scale(bandPaddingInner=0.2))
|
61 |
+
|
62 |
+
st.write('## How Revenue varies with Ratings')
|
63 |
+
st.altair_chart(alt.Chart(movies_df).mark_bar().encode(x = alt.X('Rating', title = "Ratings", axis= alt.Axis(labelAngle = -45)), y = alt.Y('Revenue', title = 'Revenue (in USD)')).properties(width = 800,height = 500).configure_scale(bandPaddingInner=0.2))
|
pages/Popular_Movies.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from Data import movies_df
|
3 |
+
import altair as alt
|
4 |
+
|
5 |
+
sort_by = st.selectbox("Select criteria to sort by",('Revenue','Rating'))
|
6 |
+
if sort_by== 'Revenue':
|
7 |
+
n = st.slider('Select a value',5, 20, 10)
|
8 |
+
st.subheader(f'Top {n} Movies by Revenue (in USD)')
|
9 |
+
st.altair_chart(alt.Chart(movies_df.sort_values(by = "Revenue", ascending=False).head(n)).mark_bar().encode(x = alt.X('Title', title = "Movie Title", axis= alt.Axis(labelAngle = -45)), color = 'Revenue', y = alt.Y('Revenue', title = 'Revenue')).properties(width = 790,height = 500).configure_scale(bandPaddingInner=0.2))
|
10 |
+
|
11 |
+
elif sort_by == 'Rating':
|
12 |
+
n = st.slider('Select a value',5, 20, 10)
|
13 |
+
st.subheader(f'Top {n} Movies/TV Shows by Rating (out of 10)')
|
14 |
+
st.altair_chart(alt.Chart(movies_df.sort_values(by = "Rating", ascending=False).head(n)).mark_bar().encode(x = alt.X('Title', title = "Movie Title", axis= alt.Axis(labelAngle = -45)), color = 'Rating', y = alt.Y('Rating', title = 'Rating')).properties(width = 790,height = 500).configure_scale(bandPaddingInner=0.2))
|
15 |
+
|
16 |
+
ops = st.multiselect("Select genres",['Action','Animation','Adventure','Fantasy','Horror','Crime','Thriller','Mystery','Drama','Comedy','History','TV Movie','Western','Science Fiction','Romance'])
|
17 |
+
if len(movies_df[movies_df['Genres'] == str(list(ops))]) != 0:
|
18 |
+
st.write(movies_df[movies_df['Genres'] == str(list(ops))].drop(['Popularity', 'Genres'], axis="columns"))
|
19 |
+
else:
|
20 |
+
st.write("No movie with given genres")
|
pages/View_Specific_Data.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from Data import movies_df, cast_df
|
3 |
+
|
4 |
+
st.header("Find Data by Movie Title")
|
5 |
+
name = st.selectbox("Enter Movie Name", movies_df["Title"].tolist())
|
6 |
+
id = movies_df.index[movies_df['Title'] == name]
|
7 |
+
st.write("### Description")
|
8 |
+
st.write(movies_df[movies_df['Title'] == name]['Description'].tolist()[0])
|
9 |
+
st.write("### Movie ID")
|
10 |
+
st.write(str(movies_df[movies_df['Title'] == name]['Id'].tolist()[0]))
|
11 |
+
st.write('### Movie Genres')
|
12 |
+
genre_list = movies_df[movies_df['Title'] == name]['Genres'].tolist()[0].lstrip('[').rstrip(']').split(",")
|
13 |
+
s = ''
|
14 |
+
for i in genre_list:
|
15 |
+
i = i.strip().strip("\'")
|
16 |
+
s += "<li>" + i + "</li>"
|
17 |
+
|
18 |
+
st.markdown("<ul>"+s+"</ul>",unsafe_allow_html=True)
|
19 |
+
st.write('### Release Date')
|
20 |
+
date, format = st.tabs(["Date","Format"])
|
21 |
+
with date:
|
22 |
+
st.write(movies_df[movies_df['Title'] == name]['Release Date'].tolist()[0])
|
23 |
+
with format:
|
24 |
+
st.caption('YYYY-MM-DD')
|
25 |
+
|
26 |
+
|
27 |
+
st.write("### Ratings")
|
28 |
+
rating, vote_count = st.tabs(["Ratings","Vote Count"])
|
29 |
+
with rating:
|
30 |
+
st.markdown("<p style = 'font-size: 16px;'>"+str(movies_df[movies_df['Title'] == name]['Rating'].tolist()[0])+"/10"+"</p>", unsafe_allow_html = True)
|
31 |
+
with vote_count:
|
32 |
+
st.write(str(movies_df[movies_df['Title'] == name]['Vote Count'].tolist()[0]))
|
33 |
+
|
34 |
+
st.write("### Revenue (in USD)")
|
35 |
+
if movies_df[movies_df['Title'] == name]['Revenue'].tolist()[0] != 0:
|
36 |
+
st.markdown("<p style = 'font-size: 18px'>$ " + str(movies_df[movies_df['Title'] == name]['Revenue'].tolist()[0])+'</p>', unsafe_allow_html = True)
|
37 |
+
else:
|
38 |
+
st.write("The revenue is unknown or N/A")
|
39 |
+
|
40 |
+
st.write("### Movie Cast")
|
41 |
+
movie_id = movies_df[movies_df["Title"] == name]["Id"].tolist()[0]
|
42 |
+
cast_list = eval(cast_df[cast_df["Movie Id"] == movie_id]['Cast'].tolist()[0])
|
43 |
+
|
44 |
+
if not cast_list:
|
45 |
+
st.write("Cast is not yet available")
|
46 |
+
|
47 |
+
s = ''
|
48 |
+
for i in cast_list:
|
49 |
+
s += "<li style='font-size: 16px; display: inline-block;'>" + i + "</li>"
|
50 |
+
|
51 |
+
st.markdown("<ol>"+s+"</ol>", unsafe_allow_html = True)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
pandas
|
3 |
+
altair
|