Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,6 @@ import pandas as pd
|
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
import seaborn as sns
|
| 5 |
import matplotlib.font_manager as fm
|
| 6 |
-
from PIL import Image
|
| 7 |
|
| 8 |
# ํฐํธ ์ค์
|
| 9 |
font_path = r"H2GTRM.TTF"
|
|
@@ -76,13 +75,23 @@ elif page == "์ฐ๋ น๋ ๋ฐ ์ฑ๋ณ์ ๋ฐ๋ฅธ ์์ 3๊ฐ ์ฅ๋ฅด":
|
|
| 76 |
# ์ฅ๋ฅด๋ณ ๋์ถ ๊ฑด์ ์ง๊ณ
|
| 77 |
genre_age_sex = df.groupby(['์ฐ๋ น๋', '์ฑ๋ณ', '์ฃผ์ ๋ถ๋ฅ๋ช
'])['๋์ถ๊ฑด์'].sum().unstack().fillna(0)
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
# ํํธ๋งต ์๊ฐํ
|
| 80 |
st.write("์ฐ๋ น๋ ๋ฐ ์ฑ๋ณ์ ๋ฐ๋ฅธ ์ฅ๋ฅด ์ ํธ๋ ํํธ๋งต")
|
| 81 |
fig, ax = plt.subplots(figsize=(12, 8))
|
| 82 |
-
sns.heatmap(genre_age_sex, annot=False, cmap='YlGnBu', linewidths=0.5, ax=ax)
|
| 83 |
-
ax.set_title('
|
| 84 |
st.pyplot(fig)
|
| 85 |
|
| 86 |
-
#
|
| 87 |
-
st.write("
|
| 88 |
-
st.
|
|
|
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
import seaborn as sns
|
| 5 |
import matplotlib.font_manager as fm
|
|
|
|
| 6 |
|
| 7 |
# ํฐํธ ์ค์
|
| 8 |
font_path = r"H2GTRM.TTF"
|
|
|
|
| 75 |
# ์ฅ๋ฅด๋ณ ๋์ถ ๊ฑด์ ์ง๊ณ
|
| 76 |
genre_age_sex = df.groupby(['์ฐ๋ น๋', '์ฑ๋ณ', '์ฃผ์ ๋ถ๋ฅ๋ช
'])['๋์ถ๊ฑด์'].sum().unstack().fillna(0)
|
| 77 |
|
| 78 |
+
# ์ฐ๋ น๋์ ์ฑ๋ณ ์ ํ
|
| 79 |
+
ages = df['์ฐ๋ น๋'].unique()
|
| 80 |
+
genders = df['์ฑ๋ณ'].unique()
|
| 81 |
+
|
| 82 |
+
selected_age = st.selectbox("์ฐ๋ น๋ ์ ํ", options=ages)
|
| 83 |
+
selected_gender = st.selectbox("์ฑ๋ณ ์ ํ", options=genders)
|
| 84 |
+
|
| 85 |
+
# ํํฐ๋ง๋ ๋ฐ์ดํฐ ์ถ์ถ
|
| 86 |
+
filtered_genres = genre_age_sex.loc[selected_age, selected_gender] if selected_age in genre_age_sex.index and selected_gender in genre_age_sex.columns else pd.Series(dtype=int)
|
| 87 |
+
|
| 88 |
# ํํธ๋งต ์๊ฐํ
|
| 89 |
st.write("์ฐ๋ น๋ ๋ฐ ์ฑ๋ณ์ ๋ฐ๋ฅธ ์ฅ๋ฅด ์ ํธ๋ ํํธ๋งต")
|
| 90 |
fig, ax = plt.subplots(figsize=(12, 8))
|
| 91 |
+
sns.heatmap(genre_age_sex.loc[[selected_age], [selected_gender]], annot=False, cmap='YlGnBu', linewidths=0.5, ax=ax)
|
| 92 |
+
ax.set_title(f'{selected_age} - {selected_gender}์ ์ฅ๋ฅด ์ ํธ๋')
|
| 93 |
st.pyplot(fig)
|
| 94 |
|
| 95 |
+
# ์ ํ๋ ์นดํ
๊ณ ๋ฆฌ์ ๋ฐ๋ฅธ ์ฃผ์ ๋ถ๋ฅ๋ช
์ถ๋ ฅ
|
| 96 |
+
st.write(f"{selected_age} - {selected_gender}์ ๋ฐ๋ฅธ ์ฃผ์ ๋ถ๋ฅ๋ช
:")
|
| 97 |
+
st.write(filtered_genres)
|