Penguni commited on
Commit
514acd5
·
verified ·
1 Parent(s): 280aeca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -21,6 +21,13 @@ def create_genre_bar_chart(df, title):
21
  genre_counts = genre_counts.head(10) # Get top 10 genres
22
  fig = px.bar(genre_counts, x='count', y='genre', orientation='h', title=title)
23
  return fig
 
 
 
 
 
 
 
24
 
25
  # Streamlit app
26
  st.title('Parental Guide Treemaps')
@@ -29,7 +36,7 @@ st.title('Parental Guide Treemaps')
29
  col1, col2 = st.columns(2)
30
 
31
  # Initialize variable for selection
32
- selection = None
33
 
34
  # Add buttons in each column
35
  with col1:
@@ -44,7 +51,9 @@ with col2:
44
  if selection == 'Movies':
45
  st.plotly_chart(create_treemap(df_movies, 'Parental Guide - Movies'), use_container_width=True)
46
  st.plotly_chart(create_genre_bar_chart(df_movies, 'Top 10 Genres - Movies'), use_container_width=True)
 
47
  elif selection == 'TV Series':
48
  st.plotly_chart(create_treemap(df_tv_series, 'Parental Guide - TV Series'), use_container_width=True)
49
  st.plotly_chart(create_genre_bar_chart(df_tv_series, 'Top 10 Genres - TV Series'), use_container_width=True)
 
50
 
 
21
  genre_counts = genre_counts.head(10) # Get top 10 genres
22
  fig = px.bar(genre_counts, x='count', y='genre', orientation='h', title=title)
23
  return fig
24
+ def create_country_map(df, title):
25
+ country_counts = df['country'].value_counts().reset_index()
26
+ country_counts.columns = ['country', 'count']
27
+ fig = px.choropleth(country_counts, locations="country", locationmode='country names',
28
+ color="count", hover_name="country",
29
+ color_continuous_scale=px.colors.sequential.Plasma, title=title)
30
+ return fig
31
 
32
  # Streamlit app
33
  st.title('Parental Guide Treemaps')
 
36
  col1, col2 = st.columns(2)
37
 
38
  # Initialize variable for selection
39
+ selection = 'Movies'
40
 
41
  # Add buttons in each column
42
  with col1:
 
51
  if selection == 'Movies':
52
  st.plotly_chart(create_treemap(df_movies, 'Parental Guide - Movies'), use_container_width=True)
53
  st.plotly_chart(create_genre_bar_chart(df_movies, 'Top 10 Genres - Movies'), use_container_width=True)
54
+ st.plotly_chart(create_country_map(df_movies, 'Global Distribution of Movies'), use_container_width=True)
55
  elif selection == 'TV Series':
56
  st.plotly_chart(create_treemap(df_tv_series, 'Parental Guide - TV Series'), use_container_width=True)
57
  st.plotly_chart(create_genre_bar_chart(df_tv_series, 'Top 10 Genres - TV Series'), use_container_width=True)
58
+ st.plotly_chart(create_country_map(df_tv_series, 'Global Distribution of TV Series'), use_container_width=True)
59