-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
65 lines (48 loc) · 2.48 KB
/
app.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
import streamlit as st
import pandas as pd
from plotly import express as px
netflix_df = pd.read_csv('NetflixOriginals.csv', encoding= 'latin-1')
st.set_page_config(page_title='Netflix Originals vs IMDB',
page_icon=':tv:',
layout='wide',
initial_sidebar_state='auto'
)
st.title('Netflix Original Movies')
st.subheader('A close look at Netflix Original Movies as compared to IMDB ratings (up to 2020)')
col1, col2, col3, col4 = st.columns(4)
col1.metric('Total Movies', netflix_df.shape[0])
col2.metric('Highest rated genre', netflix_df['Genre'].value_counts().index[0])
col3.metric('Highest IMDB Rating', netflix_df['IMDB Score'].max())
col4.metric('Lowest IMDB Rating', netflix_df['IMDB Score'].min())
#Create a plotly chart where people can select the genre
st.sidebar.title('Summary')
st.sidebar.markdown('''
With a growing libary of original movies, moving to and from IMDB to find a
suitable weekend movie can be a husssle. With this visualization, you can find a
well rated movie for you pleasure. IMDB ratings are not the holy grail of how good
or bad a movie is but its one of the essential metrics used.
''')
st.sidebar.title('Top 5 Genres')
# Top 5 Genres with the highest mean IMDB score
top_5_genres = netflix_df.groupby('Genre')['IMDB Score'].mean().sort_values(ascending=False).head(5)
st.sidebar.write(top_5_genres)
#remove header and index
st.sidebar.title('Top 5 movies')
# Top 5 movies with highest ratings
st.sidebar.write(netflix_df[['Title', 'IMDB Score']].sort_values(by='IMDB Score', ascending=False).head(5))
# create a multi-select box
genre = st.multiselect('Select Genre', netflix_df['Genre'].unique(), default=['Drama', 'Documentary'])
first_chart = px.scatter(netflix_df[netflix_df['Genre'].isin(genre)],
x='IMDB Score', y='Genre', size='IMDB Score',
color='IMDB Score', hover_name='Title', size_max=20,
title='IMDB Score vs Genre'
)
st.plotly_chart(first_chart, use_container_width=True)
st.write('''
Below is a full interactive table which you can find a range of information on the
ratings regardless of the genre. Uset the slider to filter the IMDB score on the movie
list.
''')
my_slider = st.slider('Select a range', 0.0, 10.0, (2.0, 8.0))
mask = netflix_df['IMDB Score'].between(my_slider[0], my_slider[1])
st.write(netflix_df[mask].sort_values('Title'), use_container_width=True)