Penguni commited on
Commit
afb97aa
·
verified ·
1 Parent(s): c46b8ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -150,6 +150,17 @@ def create_country_map(df, title):
150
  projection="natural earth")
151
 
152
  return fig
 
 
 
 
 
 
 
 
 
 
 
153
 
154
  # Function to create rating distribution box chart
155
  def create_rating_box_chart(df, title):
@@ -170,6 +181,7 @@ if not selection_movies and not selection_tv_series:
170
  # Displaying charts in a customized layout based on selection
171
  if selection_movies:
172
  st.subheader('Movies')
 
173
  col1_1, col1_2 = st.columns(2)
174
  with col1_1:
175
  st.plotly_chart(create_treemap(df_movies, 'Parental Guide - Movies'), use_container_width=True)
@@ -183,6 +195,7 @@ if selection_movies:
183
 
184
  elif selection_tv_series:
185
  st.subheader('TV Series')
 
186
  col1_1, col1_2 = st.columns(2)
187
  with col1_1:
188
  st.plotly_chart(create_treemap(df_tv_series, 'Parental Guide - TV Series'), use_container_width=True)
 
150
  projection="natural earth")
151
 
152
  return fig
153
+ def display_summary_metrics(df):
154
+ num_works = len(df)
155
+ num_languages = df['language'].nunique()
156
+ num_countries = df.explode('country')['country'].nunique()
157
+ num_votes = df['votes'].sum()
158
+
159
+ col1, col2, col3, col4 = st.columns(4)
160
+ col1.metric("Number of Works", num_works)
161
+ col2.metric("Number of Languages", num_languages)
162
+ col3.metric("Number of Countries", num_countries)
163
+ col4.metric("Number of Votes", num_votes)
164
 
165
  # Function to create rating distribution box chart
166
  def create_rating_box_chart(df, title):
 
181
  # Displaying charts in a customized layout based on selection
182
  if selection_movies:
183
  st.subheader('Movies')
184
+ display_summary_metrics(df_movies)
185
  col1_1, col1_2 = st.columns(2)
186
  with col1_1:
187
  st.plotly_chart(create_treemap(df_movies, 'Parental Guide - Movies'), use_container_width=True)
 
195
 
196
  elif selection_tv_series:
197
  st.subheader('TV Series')
198
+ display_summary_metrics(df_tv_series)
199
  col1_1, col1_2 = st.columns(2)
200
  with col1_1:
201
  st.plotly_chart(create_treemap(df_tv_series, 'Parental Guide - TV Series'), use_container_width=True)