kijeoung commited on
Commit
752f8c7
Β·
verified Β·
1 Parent(s): 0aefaec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
app.py CHANGED
@@ -1,4 +1,4 @@
1
- dimport gradio as gr
2
  import pandas as pd
3
  from datetime import datetime
4
  import logging
@@ -29,17 +29,17 @@ def analyze_reviews(file_path):
29
  df_recent = df[df['λ¦¬λ·°λ‚ μ§œ'].dt.year >= start_year]
30
  logger.info("졜근 3λ…„ 데이터 필터링 μ™„λ£Œ")
31
 
32
- # 년월별 리뷰 건수 계산
33
- logger.info("월별 리뷰 건수 집계 μ‹œμž‘")
34
- df_recent['λ…„μ›”'] = df_recent['λ¦¬λ·°λ‚ μ§œ'].dt.strftime('%Y-%m')
35
- review_counts = df_recent.groupby('λ…„μ›”').size().reset_index(name='리뷰건수')
36
- logger.info("월별 리뷰 건수 집계 μ™„λ£Œ")
37
 
38
  # μƒˆλ‘œμš΄ μ‹œνŠΈμ— μ €μž₯
39
- logger.info("μƒˆλ‘œμš΄ μ‹œνŠΈ '월별 리뷰건수' 생성 μ‹œμž‘")
40
  with pd.ExcelWriter(file_path, engine='openpyxl', mode='a') as writer:
41
- review_counts.to_excel(writer, sheet_name='월별 리뷰건수', index=False)
42
- logger.info("μƒˆλ‘œμš΄ μ‹œνŠΈ '월별 리뷰건수' 생성 μ™„λ£Œ")
43
 
44
  return file_path
45
  except Exception as e:
@@ -62,7 +62,3 @@ def main():
62
 
63
  if __name__ == "__main__":
64
  main()
65
-
66
- gradio==4.44.1
67
- pandas
68
- openpyxl
 
1
+ import gradio as gr
2
  import pandas as pd
3
  from datetime import datetime
4
  import logging
 
29
  df_recent = df[df['λ¦¬λ·°λ‚ μ§œ'].dt.year >= start_year]
30
  logger.info("졜근 3λ…„ 데이터 필터링 μ™„λ£Œ")
31
 
32
+ # 년도별 리뷰 건수 계산
33
+ logger.info("년도별 리뷰 건수 집계 μ‹œμž‘")
34
+ df_recent['년도'] = df_recent['λ¦¬λ·°λ‚ μ§œ'].dt.year
35
+ yearly_review_counts = df_recent.groupby('년도').size().reset_index(name='리뷰건수')
36
+ logger.info("년도별 리뷰 건수 집계 μ™„λ£Œ")
37
 
38
  # μƒˆλ‘œμš΄ μ‹œνŠΈμ— μ €μž₯
39
+ logger.info("μƒˆλ‘œμš΄ μ‹œνŠΈ 생성 μ‹œμž‘")
40
  with pd.ExcelWriter(file_path, engine='openpyxl', mode='a') as writer:
41
+ yearly_review_counts.to_excel(writer, sheet_name='년도별 리뷰건수', index=False)
42
+ logger.info("μƒˆλ‘œμš΄ μ‹œνŠΈ 생성 μ™„λ£Œ")
43
 
44
  return file_path
45
  except Exception as e:
 
62
 
63
  if __name__ == "__main__":
64
  main()