Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,8 @@ def create_genre_bar_chart(df, title):
|
|
18 |
df_exploded = df.explode('genre')
|
19 |
genre_counts = df_exploded['genre'].value_counts().reset_index()
|
20 |
genre_counts.columns = ['genre', 'count']
|
21 |
-
|
|
|
22 |
return fig
|
23 |
|
24 |
# Streamlit app
|
@@ -42,9 +43,9 @@ with col2:
|
|
42 |
# Display the corresponding treemap in the center
|
43 |
if selection == 'Movies':
|
44 |
st.plotly_chart(create_treemap(df_movies, 'Parental Guide - Movies'), use_container_width=True)
|
45 |
-
st.plotly_chart(create_genre_bar_chart(df_movies, 'Top Genres - Movies'), use_container_width=True)
|
46 |
elif selection == 'TV Series':
|
47 |
st.plotly_chart(create_treemap(df, 'Parental Guide - TV Series'), use_container_width=True)
|
48 |
|
49 |
-
st.plotly_chart(create_genre_bar_chart(df_tv_series, 'Top Genres - TV Series'), use_container_width=True)
|
50 |
|
|
|
18 |
df_exploded = df.explode('genre')
|
19 |
genre_counts = df_exploded['genre'].value_counts().reset_index()
|
20 |
genre_counts.columns = ['genre', 'count']
|
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
|
|
|
43 |
# Display the corresponding treemap in the center
|
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, 'Parental Guide - TV Series'), use_container_width=True)
|
49 |
|
50 |
+
st.plotly_chart(create_genre_bar_chart(df_tv_series, 'Top 10 Genres - TV Series'), use_container_width=True)
|
51 |
|