jonghhhh commited on
Commit
c91d609
Β·
verified Β·
1 Parent(s): 9312ce7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -12,7 +12,8 @@ def get_statistic_codes():
12
  if response.status_code == 200:
13
  data = response.json()
14
  df = pd.DataFrame(data['StatisticTableList']['row'])
15
- return df[['STAT_CODE', 'STAT_NAME']]
 
16
  else:
17
  st.error(f"Failed to retrieve data: {response.status_code}")
18
  return None
@@ -64,8 +65,8 @@ if menu == "톡계 μ½”λ“œ 쑰회 및 데이터 뢄석":
64
  # 톡계 μ½”λ“œ 쑰회 및 선택
65
  stat_codes_df = get_statistic_codes()
66
  if stat_codes_df is not None:
67
- st.dataframe(stat_codes_df)
68
- selected_code = st.selectbox("μ‘°νšŒν•  톡계 μ½”λ“œλ₯Ό μ„ νƒν•˜μ„Έμš”:", stat_codes_df['STAT_CODE'])
69
 
70
  # 톡계 데이터 쑰회 및 좜λ ₯
71
  period = st.text_input("쑰회 μ£ΌκΈ° μž…λ ₯ (예: A, Q, M):", "A")
@@ -77,6 +78,12 @@ if menu == "톡계 μ½”λ“œ 쑰회 및 데이터 뢄석":
77
  if stat_data_df is not None:
78
  st.write(f"μ„ νƒν•œ 톡계 μ½”λ“œ: {selected_code}")
79
  st.dataframe(stat_data_df)
 
 
 
 
 
 
80
 
81
  elif menu == "100λŒ€ ν†΅κ³„μ§€ν‘œ μ‹€μ‹œκ°„ 확인":
82
  st.header("100λŒ€ ν†΅κ³„μ§€ν‘œ μ‹€μ‹œκ°„ 확인")
@@ -84,3 +91,4 @@ elif menu == "100λŒ€ ν†΅κ³„μ§€ν‘œ μ‹€μ‹œκ°„ 확인":
84
  top_100_df = get_top_100_statistics()
85
  if top_100_df is not None:
86
  st.dataframe(top_100_df)
 
 
12
  if response.status_code == 200:
13
  data = response.json()
14
  df = pd.DataFrame(data['StatisticTableList']['row'])
15
+ df['μ½”λ“œμ™€ 이름'] = df['STAT_CODE'] + ": " + df['STAT_NAME']
16
+ return df[['STAT_CODE', 'μ½”λ“œμ™€ 이름']]
17
  else:
18
  st.error(f"Failed to retrieve data: {response.status_code}")
19
  return None
 
65
  # 톡계 μ½”λ“œ 쑰회 및 선택
66
  stat_codes_df = get_statistic_codes()
67
  if stat_codes_df is not None:
68
+ selected_code_name = st.selectbox("μ‘°νšŒν•  톡계 μ½”λ“œλ₯Ό μ„ νƒν•˜μ„Έμš”:", stat_codes_df['μ½”λ“œμ™€ 이름'])
69
+ selected_code = selected_code_name.split(": ")[0] # 톡계 μ½”λ“œλ§Œ μΆ”μΆœ
70
 
71
  # 톡계 데이터 쑰회 및 좜λ ₯
72
  period = st.text_input("쑰회 μ£ΌκΈ° μž…λ ₯ (예: A, Q, M):", "A")
 
78
  if stat_data_df is not None:
79
  st.write(f"μ„ νƒν•œ 톡계 μ½”λ“œ: {selected_code}")
80
  st.dataframe(stat_data_df)
81
+
82
+ # Excel 파일둜 μ €μž₯
83
+ st.write("데이터λ₯Ό Excel 파일둜 μ €μž₯ν•˜λ €λ©΄ μ•„λž˜ λ²„νŠΌμ„ ν΄λ¦­ν•˜μ„Έμš”.")
84
+ if st.button("Excel둜 μ €μž₯"):
85
+ stat_data_df.to_excel(f"{selected_code}_data.xlsx", index=False)
86
+ st.success(f"데이터가 {selected_code}_data.xlsx 파일둜 μ €μž₯λ˜μ—ˆμŠ΅λ‹ˆλ‹€.")
87
 
88
  elif menu == "100λŒ€ ν†΅κ³„μ§€ν‘œ μ‹€μ‹œκ°„ 확인":
89
  st.header("100λŒ€ ν†΅κ³„μ§€ν‘œ μ‹€μ‹œκ°„ 확인")
 
91
  top_100_df = get_top_100_statistics()
92
  if top_100_df is not None:
93
  st.dataframe(top_100_df)
94
+