Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import altair as alt | |
| # Streamlit ํ์ด์ง ์ค์ | |
| st.set_page_config(page_title="๋์ ๋์ถ ์์ ์์ธก", layout="wide") | |
| # ํ์ด์ง์ ์ด๋ฏธ์ง ๋๋ํ ํ์ | |
| st.title("๋์ ๋์ถ ์์ธก ๋ถ์") | |
| # ์ด๋ฏธ์ง ํ์ผ ๊ฒฝ๋ก | |
| image1 = "image-1.jpeg" | |
| image2 = "image-2.jpeg" | |
| # ๋ ๊ฐ์ ์ด๋ฏธ์ง๋ฅผ ๋๋ํ ๋ฐฐ์น | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| st.image(image1, caption="์ด๋ฏธ์ง 1", use_column_width=True) | |
| with col2: | |
| st.image(image2, caption="์ด๋ฏธ์ง 2", use_column_width=True) | |
| # ์์ ํ์ผ ๊ฒฝ๋ก | |
| file_path = r'book_analysis_summary.xlsx' | |
| # ์์ ํ์ผ ์ฝ๊ธฐ | |
| df = pd.read_excel(file_path) | |
| # ๊ทธ๋ฃน ์ ํ | |
| group_column = '์ฐ๋ น_์ฑ๋ณ' | |
| if group_column in df.columns: | |
| st.sidebar.title("๊ทธ๋ฃน ์ ํ") | |
| groups = df[group_column].unique() | |
| selected_group = st.sidebar.selectbox("๊ทธ๋ฃน ์ ํ", groups) | |
| # ์ ํ๋ ๊ทธ๋ฃน์ ๋ฐ์ดํฐ ํํฐ๋ง | |
| filtered_data = df[df[group_column] == selected_group] | |
| # ํ์ํ ์ด๋ง ์ถ์ถ (์์ธก ๋์ถ๊ฑด์, ์ค์ ๋์ถ๊ฑด์) | |
| filtered_data = filtered_data[['์ฐ๋ น_์ฑ๋ณ', '์์ธก ๋์ถ๊ฑด์', '์ค์ ๋์ถ๊ฑด์']] | |
| # ํํฐ๋ง๋ ๋ฐ์ดํฐ ํ์ | |
| st.write(f"์ ํํ ์นดํ ๊ณ ๋ฆฌ: {selected_group}") | |
| st.write(filtered_data) | |
| # ๋ฐ์ดํฐ๋ฅผ ์ธ๋ก ๋ง๋ ๊ทธ๋ํ๋ก ์๊ฐํ | |
| chart_data = filtered_data.melt(id_vars='์ฐ๋ น_์ฑ๋ณ', var_name='Type', value_name='Count') | |
| bar_chart = alt.Chart(chart_data).mark_bar().encode( | |
| x=alt.X('์ฐ๋ น_์ฑ๋ณ:N', title='์ฐ๋ น๋ ๋ฐ ์ฑ๋ณ'), | |
| y=alt.Y('Count:Q', title='๋์ถ๊ฑด์'), | |
| color='Type:N', | |
| column='Type:N' | |
| ).properties( | |
| width=300, | |
| height=400 | |
| ).configure_axis( | |
| labelFontSize=12, | |
| titleFontSize=14 | |
| ) | |
| st.altair_chart(bar_chart, use_container_width=True) | |