SeungHyun111 commited on
Commit
8721276
ยท
verified ยท
1 Parent(s): e75fb3b

Upload 2 files

Browse files
Files changed (2) hide show
  1. requirements.txt +0 -0
  2. streamlit1.py +58 -0
requirements.txt ADDED
Binary file (6.64 kB). View file
 
streamlit1.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+ from matplotlib import font_manager as fm
5
+
6
+ # ํฐํŠธ ํŒŒ์ผ ๊ฒฝ๋กœ ์„ค์ •
7
+ font_path = r"C:\Users\user\Desktop\๋„์„œ๊ด€_๊ณต๋ชจ์ „\์ตœ์ข…\H2GTRM.TTF"
8
+
9
+ # ํฐํŠธ ๋“ฑ๋ก
10
+ font_prop = fm.FontProperties(fname=font_path)
11
+ plt.rcParams['font.family'] = font_prop.get_name()
12
+
13
+ # Excel ํŒŒ์ผ ๊ฒฝ๋กœ
14
+ excel_path = "C:/Users/user/Desktop/๋„์„œ๊ด€_๊ณต๋ชจ์ „/์ตœ์ข…/12_๋‹ค๋Œ€์ถœ๊ทธ๋ฃน/๋„์„œ ๋Œ€์ถœ ํŒจํ„ด ๋ถ„์„/์ƒ์œ„_5_๋„์„œ.xlsx"
15
+
16
+ # Excel ํŒŒ์ผ์˜ ์‹œํŠธ๋“ค์„ ์ฝ์–ด์˜ค๊ธฐ
17
+ @st.cache_data
18
+ def load_excel_sheets(file_path):
19
+ xls = pd.ExcelFile(file_path)
20
+ sheets = {}
21
+ for sheet_name in xls.sheet_names:
22
+ sheets[sheet_name] = pd.read_excel(xls, sheet_name)
23
+ return sheets
24
+
25
+ sheets = load_excel_sheets(excel_path)
26
+ sheet_names = list(sheets.keys())
27
+
28
+ # Streamlit ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜
29
+ st.title('์—ฐ๋ น/์„ฑ๋ณ„์— ๋”ฐ๋ฅธ ์ƒ์œ„ 5๊ฐœ ๋Œ€์ถœ ๋„์„œ')
30
+
31
+
32
+ # ์นดํ…Œ๊ณ ๋ฆฌ ์„ ํƒ
33
+ selected_category = st.selectbox('์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ ์„ ํƒํ•˜์„ธ์š”:', sheet_names)
34
+
35
+ # ์„ ํƒํ•œ ์นดํ…Œ๊ณ ๋ฆฌ์˜ Excel ๋ฐ์ดํ„ฐ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
36
+ df = sheets[selected_category]
37
+
38
+ # ๋ฐ์ดํ„ฐ ํ”„๋ ˆ์ž„ ํ™•์ธ
39
+ st.write(f'์„ ํƒํ•œ ์นดํ…Œ๊ณ ๋ฆฌ: {selected_category}')
40
+ st.dataframe(df)
41
+
42
+ # ๋ฐ์ดํ„ฐ ํ”„๋ ˆ์ž„์—์„œ ์ƒ์œ„ 5๊ฐœ ๋„์„œ์™€ ๋Œ€์ถœ ๊ฑด์ˆ˜ ์ถ”์ถœ
43
+ top_5_books = df.head(5)
44
+
45
+ # ๋ง‰๋Œ€ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ
46
+ fig, ax = plt.subplots(figsize=(10, 6)) # ๊ทธ๋ž˜ํ”„ ํฌ๊ธฐ ์กฐ์ •
47
+ ax.bar(top_5_books['๋„์„œ๋ช…'], top_5_books['๋Œ€์ถœ๊ฑด์ˆ˜'])
48
+
49
+ # ๋ ˆ์ด๋ธ” ํšŒ์ „ ๋ฐ ๋ ˆ์ด๋ธ” ๊ฐ„๊ฒฉ ์กฐ์ •
50
+ ax.set_xlabel('๋„์„œ๋ช…')
51
+ ax.set_ylabel('๋Œ€์ถœ๊ฑด์ˆ˜')
52
+ ax.set_title(f'{selected_category} - ์ƒ์œ„ 5๊ฐœ ๋„์„œ ๋Œ€์ถœ ๊ฑด์ˆ˜')
53
+
54
+ # X์ถ• ๋ ˆ์ด๋ธ” ํšŒ์ „
55
+ plt.xticks(rotation=45, ha='right')
56
+
57
+ # Streamlit์—์„œ ๊ทธ๋ž˜ํ”„ ํ‘œ์‹œ
58
+ st.pyplot(fig)