Penguni commited on
Commit
eeb4dbe
·
verified ·
1 Parent(s): 52eef11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -129,7 +129,7 @@ def create_genre_bar_chart(df, title):
129
  df_exploded = df.explode('genre')
130
  genre_counts = df_exploded['genre'].value_counts().reset_index()
131
  genre_counts.columns = ['genre', 'count']
132
- genre_counts = genre_counts.head(10) # Top 10 genres
133
  fig = px.bar(genre_counts, x='count', y='genre', orientation='h', title=title)
134
  return fig
135
 
@@ -164,6 +164,8 @@ st.title('Parental Guide Analysis')
164
  col1, col2 = st.columns(2)
165
  selection_movies = col1.button('Movies')
166
  selection_tv_series = col2.button('TV Series')
 
 
167
 
168
  # Displaying charts in a customized layout based on selection
169
  if selection_movies:
@@ -175,9 +177,9 @@ if selection_movies:
175
  st.plotly_chart(create_genre_bar_chart(df_movies, 'Top 10 Genres - Movies'), use_container_width=True)
176
  col2_1, col2_2 = st.columns(2)
177
  with col2_1:
178
- st.plotly_chart(create_rating_box_chart(df_movies, 'Rating Distribution - Movies'), use_container_width=True)
179
- with col2_2:
180
  st.plotly_chart(create_country_map(df_movies, 'Global Distribution of Movies'), use_container_width=True)
 
 
181
 
182
  elif selection_tv_series:
183
  st.subheader('TV Series')
@@ -188,6 +190,6 @@ elif selection_tv_series:
188
  st.plotly_chart(create_genre_bar_chart(df_tv_series, 'Top 10 Genres - TV Series'), use_container_width=True)
189
  col2_1, col2_2 = st.columns(2)
190
  with col2_1:
191
- st.plotly_chart(create_rating_box_chart(df_tv_series, 'Rating Distribution - TV Series'), use_container_width=True)
192
- with col2_2:
193
  st.plotly_chart(create_country_map(df_tv_series, 'Global Distribution of TV Series'), use_container_width=True)
 
 
 
129
  df_exploded = df.explode('genre')
130
  genre_counts = df_exploded['genre'].value_counts().reset_index()
131
  genre_counts.columns = ['genre', 'count']
132
+ genre_counts = genre_counts.head(10).sort_values('count', ascending=True) # Top 10 genres sorted with the largest on top
133
  fig = px.bar(genre_counts, x='count', y='genre', orientation='h', title=title)
134
  return fig
135
 
 
164
  col1, col2 = st.columns(2)
165
  selection_movies = col1.button('Movies')
166
  selection_tv_series = col2.button('TV Series')
167
+ if not selection_movies and not selection_tv_series:
168
+ selection_movies = True
169
 
170
  # Displaying charts in a customized layout based on selection
171
  if selection_movies:
 
177
  st.plotly_chart(create_genre_bar_chart(df_movies, 'Top 10 Genres - Movies'), use_container_width=True)
178
  col2_1, col2_2 = st.columns(2)
179
  with col2_1:
 
 
180
  st.plotly_chart(create_country_map(df_movies, 'Global Distribution of Movies'), use_container_width=True)
181
+ with col2_2:
182
+ st.plotly_chart(create_rating_box_chart(df_movies, 'Rating Distribution - Movies'), use_container_width=True)
183
 
184
  elif selection_tv_series:
185
  st.subheader('TV Series')
 
190
  st.plotly_chart(create_genre_bar_chart(df_tv_series, 'Top 10 Genres - TV Series'), use_container_width=True)
191
  col2_1, col2_2 = st.columns(2)
192
  with col2_1:
 
 
193
  st.plotly_chart(create_country_map(df_tv_series, 'Global Distribution of TV Series'), use_container_width=True)
194
+ with col2_2:
195
+ st.plotly_chart(create_rating_box_chart(df_tv_series, 'Rating Distribution - TV Series'), use_container_width=True)