Spaces:
No application file
No application file
Upload 2 files
Browse files- requirements.txt +0 -0
- 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)
|