Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ file_path = "book_introductions_with_predictions.xlsx"
|
|
| 6 |
df = pd.read_excel(file_path)
|
| 7 |
|
| 8 |
# ์ฑ
์ ๋ชฉ ๊ฒ์
|
| 9 |
-
st.title("
|
| 10 |
|
| 11 |
# ์ฌ์ฉ์๊ฐ ๊ฒ์ํ ์ฑ
์ ๋ชฉ ์
๋ ฅ
|
| 12 |
search_title = st.text_input("์ฑ
์ ๋ชฉ์ ์
๋ ฅํ์ธ์:")
|
|
@@ -26,17 +26,33 @@ st.title("๊ฐ ๊ฐ์ ๋ณ ํ๋ฅ ์์ 10๊ฐ์ ์ฑ
")
|
|
| 26 |
# ํ๋ฅ ๋ฐ์ดํฐ๋ฅผ ๊ณต๋ฐฑ์ผ๋ก ๋ถ๋ฆฌํ์ฌ ๊ธ์ , ๋ถ์ , ์ค๋ฆฝ ์ด๋ก ๋ถ๋ฆฌ
|
| 27 |
df[['๊ธ์ ', '๋ถ์ ', '์ค๋ฆฝ']] = df['ํ๋ฅ '].str.strip('[]').str.split(expand=True).astype(float)
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# ๊ธ์ ํ๋ฅ ์์ 10๊ฐ
|
| 30 |
-
top_positive = df
|
| 31 |
st.subheader("๊ธ์ ํ๋ฅ ์์ 10๊ฐ ์ฑ
")
|
| 32 |
st.table(top_positive)
|
| 33 |
|
| 34 |
# ๋ถ์ ํ๋ฅ ์์ 10๊ฐ
|
| 35 |
-
top_negative = df
|
| 36 |
st.subheader("๋ถ์ ํ๋ฅ ์์ 10๊ฐ ์ฑ
")
|
| 37 |
st.table(top_negative)
|
| 38 |
|
| 39 |
# ์ค๋ฆฝ ํ๋ฅ ์์ 10๊ฐ
|
| 40 |
-
top_neutral = df
|
| 41 |
st.subheader("์ค๋ฆฝ ํ๋ฅ ์์ 10๊ฐ ์ฑ
")
|
| 42 |
st.table(top_neutral)
|
|
|
|
| 6 |
df = pd.read_excel(file_path)
|
| 7 |
|
| 8 |
# ์ฑ
์ ๋ชฉ ๊ฒ์
|
| 9 |
+
st.title("์ฑ
์๊ฐ๊ธ ๊ธฐ๋ฐ ๊ฐ์ ๋ถ์")
|
| 10 |
|
| 11 |
# ์ฌ์ฉ์๊ฐ ๊ฒ์ํ ์ฑ
์ ๋ชฉ ์
๋ ฅ
|
| 12 |
search_title = st.text_input("์ฑ
์ ๋ชฉ์ ์
๋ ฅํ์ธ์:")
|
|
|
|
| 26 |
# ํ๋ฅ ๋ฐ์ดํฐ๋ฅผ ๊ณต๋ฐฑ์ผ๋ก ๋ถ๋ฆฌํ์ฌ ๊ธ์ , ๋ถ์ , ์ค๋ฆฝ ์ด๋ก ๋ถ๋ฆฌ
|
| 27 |
df[['๊ธ์ ', '๋ถ์ ', '์ค๋ฆฝ']] = df['ํ๋ฅ '].str.strip('[]').str.split(expand=True).astype(float)
|
| 28 |
|
| 29 |
+
def get_top_n_unique(df, column, n=10):
|
| 30 |
+
# ์์ n๊ฐ์ ๋์๋ฅผ ์ถ์ถํ๋ ์ค๋ณต ์ ๊ฑฐ
|
| 31 |
+
top_n = df.sort_values(by=column, ascending=False)
|
| 32 |
+
top_n_unique = []
|
| 33 |
+
seen_titles = set()
|
| 34 |
+
|
| 35 |
+
for index, row in top_n.iterrows():
|
| 36 |
+
if len(top_n_unique) >= n:
|
| 37 |
+
break
|
| 38 |
+
title = row['์ฑ
์ ๋ชฉ']
|
| 39 |
+
if title not in seen_titles:
|
| 40 |
+
top_n_unique.append(row)
|
| 41 |
+
seen_titles.add(title)
|
| 42 |
+
|
| 43 |
+
return pd.DataFrame(top_n_unique)[['์ฑ
์ ๋ชฉ', column]]
|
| 44 |
+
|
| 45 |
# ๊ธ์ ํ๋ฅ ์์ 10๊ฐ
|
| 46 |
+
top_positive = get_top_n_unique(df, '๊ธ์ ', n=10)
|
| 47 |
st.subheader("๊ธ์ ํ๋ฅ ์์ 10๊ฐ ์ฑ
")
|
| 48 |
st.table(top_positive)
|
| 49 |
|
| 50 |
# ๋ถ์ ํ๋ฅ ์์ 10๊ฐ
|
| 51 |
+
top_negative = get_top_n_unique(df, '๋ถ์ ', n=10)
|
| 52 |
st.subheader("๋ถ์ ํ๋ฅ ์์ 10๊ฐ ์ฑ
")
|
| 53 |
st.table(top_negative)
|
| 54 |
|
| 55 |
# ์ค๋ฆฝ ํ๋ฅ ์์ 10๊ฐ
|
| 56 |
+
top_neutral = get_top_n_unique(df, '์ค๋ฆฝ', n=10)
|
| 57 |
st.subheader("์ค๋ฆฝ ํ๋ฅ ์์ 10๊ฐ ์ฑ
")
|
| 58 |
st.table(top_neutral)
|