Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,6 @@ import seaborn as sns
|
|
| 6 |
import matplotlib.font_manager as fm
|
| 7 |
from matplotlib import rc
|
| 8 |
|
| 9 |
-
|
| 10 |
# μ¬μ΄λλ°μ λͺ©μ°¨ μΆκ°
|
| 11 |
st.sidebar.title("λͺ©μ°¨")
|
| 12 |
page = st.sidebar.radio("νμ΄μ§ μ ν", ["μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 5κ° λμΆ λμ", "μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 3κ° μ₯λ₯΄"])
|
|
@@ -19,6 +18,16 @@ def load_data(file_path):
|
|
| 19 |
st.error(f"λ°μ΄ν°λ₯Ό λ‘λνλ λμ μ€λ₯κ° λ°μνμ΅λλ€: {e}")
|
| 20 |
return pd.DataFrame()
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
if page == "μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 5κ° λμΆ λμ":
|
| 23 |
st.title("μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 5κ° λμΆ λμ")
|
| 24 |
|
|
@@ -50,7 +59,7 @@ if page == "μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 5κ° λμΆ λμ":
|
|
| 50 |
|
| 51 |
# λ§λ κ·Έλν μκ°ν
|
| 52 |
if not filtered_books.empty:
|
| 53 |
-
|
| 54 |
st.write(f"μμ 5 λμ (μ°λ Ήλ: {selected_age}, μ±λ³: {selected_gender})")
|
| 55 |
fig, ax = plt.subplots(figsize=(10, 6))
|
| 56 |
sns.barplot(data=filtered_books, x='λμλͺ
', y='λμΆκ±΄μ', palette='viridis', ax=ax)
|
|
@@ -65,7 +74,7 @@ if page == "μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 5κ° λμΆ λμ":
|
|
| 65 |
elif page == "μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 3κ° μ₯λ₯΄":
|
| 66 |
st.title("μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 3κ° μ₯λ₯΄")
|
| 67 |
|
| 68 |
-
|
| 69 |
df = load_data(r'μμ_3_μ₯λ₯΄.xlsx')
|
| 70 |
if df.empty:
|
| 71 |
st.stop()
|
|
|
|
| 6 |
import matplotlib.font_manager as fm
|
| 7 |
from matplotlib import rc
|
| 8 |
|
|
|
|
| 9 |
# μ¬μ΄λλ°μ λͺ©μ°¨ μΆκ°
|
| 10 |
st.sidebar.title("λͺ©μ°¨")
|
| 11 |
page = st.sidebar.radio("νμ΄μ§ μ ν", ["μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 5κ° λμΆ λμ", "μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 3κ° μ₯λ₯΄"])
|
|
|
|
| 18 |
st.error(f"λ°μ΄ν°λ₯Ό λ‘λνλ λμ μ€λ₯κ° λ°μνμ΅λλ€: {e}")
|
| 19 |
return pd.DataFrame()
|
| 20 |
|
| 21 |
+
# ν°νΈ μ€μ
|
| 22 |
+
def set_font():
|
| 23 |
+
font_path = 'NanumGothic-Regular.ttf' # κ°μ λλ ν 리 λ΄μ ν°νΈ νμΌ κ²½λ‘
|
| 24 |
+
if not os.path.isfile(font_path):
|
| 25 |
+
st.error(f"ν°νΈ νμΌμ μ°Ύμ μ μμ΅λλ€: {font_path}")
|
| 26 |
+
return
|
| 27 |
+
|
| 28 |
+
font_prop = fm.FontProperties(fname=font_path)
|
| 29 |
+
rc('font', family=font_prop.get_name())
|
| 30 |
+
|
| 31 |
if page == "μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 5κ° λμΆ λμ":
|
| 32 |
st.title("μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 5κ° λμΆ λμ")
|
| 33 |
|
|
|
|
| 59 |
|
| 60 |
# λ§λ κ·Έλν μκ°ν
|
| 61 |
if not filtered_books.empty:
|
| 62 |
+
set_font()
|
| 63 |
st.write(f"μμ 5 λμ (μ°λ Ήλ: {selected_age}, μ±λ³: {selected_gender})")
|
| 64 |
fig, ax = plt.subplots(figsize=(10, 6))
|
| 65 |
sns.barplot(data=filtered_books, x='λμλͺ
', y='λμΆκ±΄μ', palette='viridis', ax=ax)
|
|
|
|
| 74 |
elif page == "μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 3κ° μ₯λ₯΄":
|
| 75 |
st.title("μ°λ Ήλ λ° μ±λ³μ λ°λ₯Έ μμ 3κ° μ₯λ₯΄")
|
| 76 |
|
| 77 |
+
# λ°μ΄ν° λ‘λ
|
| 78 |
df = load_data(r'μμ_3_μ₯λ₯΄.xlsx')
|
| 79 |
if df.empty:
|
| 80 |
st.stop()
|