Penguni commited on
Commit
dee0925
·
verified ·
1 Parent(s): 7421eb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -18
app.py CHANGED
@@ -2,21 +2,6 @@ import streamlit as st
2
  import pandas as pd
3
  import plotly.express as px
4
 
5
- # Function to assign color based on count
6
- def assign_color(count):
7
- if count <= 10:
8
- return '1-10'
9
- elif count <= 50:
10
- return '10-50'
11
- elif count <= 100:
12
- return '50-100'
13
- elif count <= 500:
14
- return '100-500'
15
- elif count <= 1000:
16
- return '500-1000'
17
- else:
18
- return '>1000'
19
-
20
  # Country mapping dictionary
21
  country_mapping = {
22
  'United States': 'USA',
@@ -124,7 +109,7 @@ country_mapping = {
124
  'Maldives': 'MDV'
125
  }
126
 
127
- # Load your dataframes
128
  df_movies = pd.read_csv('movies.csv')
129
  df_tv_series = pd.read_csv('tv_series.csv')
130
 
@@ -171,6 +156,11 @@ def create_country_map(df, title):
171
 
172
  return fig
173
 
 
 
 
 
 
174
  # Streamlit app
175
  st.title('Parental Guide Analysis')
176
 
@@ -189,12 +179,14 @@ with col2:
189
  if st.button('TV Series'):
190
  selection = 'TV Series'
191
 
192
- # Display treemap, genre bar chart, and choropleth map based on selection
193
  if selection == 'Movies':
194
  st.plotly_chart(create_treemap(df_movies, 'Parental Guide - Movies'), use_container_width=True)
195
  st.plotly_chart(create_genre_bar_chart(df_movies, 'Top 10 Genres - Movies'), use_container_width=True)
 
196
  st.plotly_chart(create_country_map(df_movies, 'Global Distribution of Movies'), use_container_width=True)
197
  elif selection == 'TV Series':
198
  st.plotly_chart(create_treemap(df_tv_series, 'Parental Guide - TV Series'), use_container_width=True)
199
  st.plotly_chart(create_genre_bar_chart(df_tv_series, 'Top 10 Genres - TV Series'), use_container_width=True)
200
- st.plotly_chart(create_country_map(df_tv_series, 'Global Distribution of TV Series'), use_container_width=True)
 
 
2
  import pandas as pd
3
  import plotly.express as px
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  # Country mapping dictionary
6
  country_mapping = {
7
  'United States': 'USA',
 
109
  'Maldives': 'MDV'
110
  }
111
 
112
+ # Load your dataframes (replace with actual CSV filenames)
113
  df_movies = pd.read_csv('movies.csv')
114
  df_tv_series = pd.read_csv('tv_series.csv')
115
 
 
156
 
157
  return fig
158
 
159
+ # Function to create rating distribution box chart
160
+ def create_rating_box_chart(df, title):
161
+ fig = px.box(df, x="rating", points="all", title=title)
162
+ return fig
163
+
164
  # Streamlit app
165
  st.title('Parental Guide Analysis')
166
 
 
179
  if st.button('TV Series'):
180
  selection = 'TV Series'
181
 
182
+ # Display treemap, genre bar chart, rating distribution, and choropleth map based on selection
183
  if selection == 'Movies':
184
  st.plotly_chart(create_treemap(df_movies, 'Parental Guide - Movies'), use_container_width=True)
185
  st.plotly_chart(create_genre_bar_chart(df_movies, 'Top 10 Genres - Movies'), use_container_width=True)
186
+ st.plotly_chart(create_rating_box_chart(df_movies, 'Rating Distribution - Movies'), use_container_width=True)
187
  st.plotly_chart(create_country_map(df_movies, 'Global Distribution of Movies'), use_container_width=True)
188
  elif selection == 'TV Series':
189
  st.plotly_chart(create_treemap(df_tv_series, 'Parental Guide - TV Series'), use_container_width=True)
190
  st.plotly_chart(create_genre_bar_chart(df_tv_series, 'Top 10 Genres - TV Series'), use_container_width=True)
191
+ st.plotly_chart(create_rating_box_chart(df_tv_series, 'Rating Distribution - TV Series'), use_container_width=True)
192
+ st.plotly_chart(create_country_map(df_tv_series, 'Global Distribution of TV Series'), use_container_width=True)