Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ import gradio as gr
|
|
| 2 |
import pandas as pd
|
| 3 |
from datetime import datetime
|
| 4 |
import logging
|
| 5 |
-
import matplotlib.pyplot as plt
|
| 6 |
|
| 7 |
# λ‘κ·Έ μ€μ
|
| 8 |
logging.basicConfig(level=logging.INFO)
|
|
@@ -30,31 +29,17 @@ def analyze_reviews(file_path):
|
|
| 30 |
df_recent = df[df['리뷰λ μ§'].dt.year >= start_year]
|
| 31 |
logger.info("μ΅κ·Ό 3λ
λ°μ΄ν° νν°λ§ μλ£")
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
logger.info("
|
| 35 |
-
df_recent['
|
| 36 |
-
|
| 37 |
-
logger.info("
|
| 38 |
|
| 39 |
-
#
|
| 40 |
-
logger.info("
|
| 41 |
-
plt.figure(figsize=(10, 6))
|
| 42 |
-
plt.bar(monthly_review_counts['λ
μ'], monthly_review_counts['리뷰건μ'], color='skyblue')
|
| 43 |
-
plt.xlabel('λ
μ')
|
| 44 |
-
plt.ylabel('리뷰 건μ')
|
| 45 |
-
plt.title('μ΅κ·Ό 3λ
μλ³ λ¦¬λ·° 건μ')
|
| 46 |
-
plt.xticks(rotation=45)
|
| 47 |
-
graph_path = file_path.replace('.xlsx', '_graph.png')
|
| 48 |
-
plt.tight_layout()
|
| 49 |
-
plt.savefig(graph_path)
|
| 50 |
-
plt.close()
|
| 51 |
-
logger.info("κ·Έλν μμ± μλ£")
|
| 52 |
-
|
| 53 |
-
# μλ‘μ΄ μνΈμ κ·Έλν μ μ₯
|
| 54 |
-
logger.info("μλ‘μ΄ μνΈ μμ± μμ")
|
| 55 |
with pd.ExcelWriter(file_path, engine='openpyxl', mode='a') as writer:
|
| 56 |
-
|
| 57 |
-
logger.info("μλ‘μ΄
|
| 58 |
|
| 59 |
return file_path
|
| 60 |
except Exception as e:
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
from datetime import datetime
|
| 4 |
import logging
|
|
|
|
| 5 |
|
| 6 |
# λ‘κ·Έ μ€μ
|
| 7 |
logging.basicConfig(level=logging.INFO)
|
|
|
|
| 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:
|