dltmdgus commited on
Commit
bc34780
Β·
verified Β·
1 Parent(s): f0b1898

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -4,18 +4,15 @@ import matplotlib.pyplot as plt
4
  import seaborn as sns
5
  import matplotlib.font_manager as fm
6
 
7
-
8
  # 폰트 μ„€μ •
9
  font_path = r"NanumGothic.ttf" # 폰트 파일 경둜 μ„€μ •
10
- font_prop = fm.FontProperties(fname=font_path, size=12)
11
- plt.rcParams['font.family'] = 'Nanum Gothic' # 폰트 이름을 직접 μ„€μ •
12
  plt.rcParams['axes.unicode_minus'] = False
13
 
14
  # μ‚¬μ΄λ“œλ°”μ— λͺ©μ°¨ μΆ”κ°€
15
  st.sidebar.title("λͺ©μ°¨")
16
- page = st.sidebar.radio("νŽ˜μ΄μ§€ 선택", [ "μ—°λ ΉλŒ€ 및 성별에 λ”°λ₯Έ μƒμœ„ 5개 λŒ€μΆœ λ„μ„œ", "μ—°λ ΉλŒ€ 및 성별에 λ”°λ₯Έ μƒμœ„ 3개 μž₯λ₯΄"])
17
-
18
-
19
 
20
  if page == "μ—°λ ΉλŒ€ 및 성별에 λ”°λ₯Έ μƒμœ„ 5개 λŒ€μΆœ λ„μ„œ":
21
  st.title("μ—°λ ΉλŒ€ 및 성별에 λ”°λ₯Έ μƒμœ„ 5개 λŒ€μΆœ λ„μ„œ")
@@ -30,7 +27,9 @@ if page == "μ—°λ ΉλŒ€ 및 성별에 λ”°λ₯Έ μƒμœ„ 5개 λŒ€μΆœ λ„μ„œ":
30
 
31
  # μƒμœ„ 5개 λ„μ„œ μΆ”μΆœ ν•¨μˆ˜
32
  def get_top_books(data, top_n=5):
33
- return data.groupby(['μ—°λ Ή', '성별']).apply(lambda x: x.nlargest(top_n, 'λŒ€μΆœκ±΄μˆ˜')).reset_index(drop=True)
 
 
34
 
35
  # μƒμœ„ 5개의 λ„μ„œ 데이터 μΆ”μΆœ
36
  top_books = get_top_books(book_patterns)
 
4
  import seaborn as sns
5
  import matplotlib.font_manager as fm
6
 
 
7
  # 폰트 μ„€μ •
8
  font_path = r"NanumGothic.ttf" # 폰트 파일 경둜 μ„€μ •
9
+ font_prop = fm.FontProperties(fname=font_path)
10
+ plt.rcParams['font.family'] = font_prop.get_name() # λ˜λŠ” 직접 폰트 이름을 μ‚¬μš©: 'Nanum Gothic'
11
  plt.rcParams['axes.unicode_minus'] = False
12
 
13
  # μ‚¬μ΄λ“œλ°”μ— λͺ©μ°¨ μΆ”κ°€
14
  st.sidebar.title("λͺ©μ°¨")
15
+ page = st.sidebar.radio("νŽ˜μ΄μ§€ 선택", ["μ—°λ ΉλŒ€ 및 성별에 λ”°λ₯Έ μƒμœ„ 5개 λŒ€μΆœ λ„μ„œ", "μ—°λ ΉλŒ€ 및 성별에 λ”°λ₯Έ μƒμœ„ 3개 μž₯λ₯΄"])
 
 
16
 
17
  if page == "μ—°λ ΉλŒ€ 및 성별에 λ”°λ₯Έ μƒμœ„ 5개 λŒ€μΆœ λ„μ„œ":
18
  st.title("μ—°λ ΉλŒ€ 및 성별에 λ”°λ₯Έ μƒμœ„ 5개 λŒ€μΆœ λ„μ„œ")
 
27
 
28
  # μƒμœ„ 5개 λ„μ„œ μΆ”μΆœ ν•¨μˆ˜
29
  def get_top_books(data, top_n=5):
30
+ return data.groupby(['μ—°λ Ή', '성별']) \
31
+ .apply(lambda x: x.nlargest(top_n, 'λŒ€μΆœκ±΄μˆ˜')) \
32
+ .reset_index(drop=True)
33
 
34
  # μƒμœ„ 5개의 λ„μ„œ 데이터 μΆ”μΆœ
35
  top_books = get_top_books(book_patterns)