|
|
import pandas as pd |
|
|
import streamlit as st |
|
|
|
|
|
|
|
|
file_path = "book_introductions_with_predictions.xlsx" |
|
|
df = pd.read_excel(file_path) |
|
|
|
|
|
|
|
|
st.title("์ฑ
์๊ฐ๊ธ ๊ธฐ๋ฐ ๊ฐ์ ๋ถ์") |
|
|
|
|
|
|
|
|
search_title = st.text_input("์ฑ
์ ๋ชฉ์ ์
๋ ฅํ์ธ์:") |
|
|
|
|
|
if search_title: |
|
|
|
|
|
result = df[df['์ฑ
์ ๋ชฉ'] == search_title] |
|
|
|
|
|
if not result.empty: |
|
|
st.write(f"**{search_title}**์ ๋ํ ์ต์ข
๊ฐ์ : **{result.iloc[0]['์ต์ข
๊ฐ์ ']}**") |
|
|
else: |
|
|
st.write("ํด๋น ์ฑ
์ ๋ชฉ์ ์ฐพ์ ์ ์์ต๋๋ค.") |
|
|
|
|
|
|
|
|
st.title("๊ฐ ๊ฐ์ ๋ณ ํ๋ฅ ์์ 10๊ฐ์ ์ฑ
") |
|
|
|
|
|
|
|
|
df[['๊ธ์ ', '๋ถ์ ', '์ค๋ฆฝ']] = df['ํ๋ฅ '].str.strip('[]').str.split(expand=True).astype(float) |
|
|
|
|
|
def get_top_n_unique(df, column, n=10): |
|
|
|
|
|
top_n = df.sort_values(by=column, ascending=False) |
|
|
top_n_unique = [] |
|
|
seen_titles = set() |
|
|
|
|
|
for index, row in top_n.iterrows(): |
|
|
if len(top_n_unique) >= n: |
|
|
break |
|
|
title = row['์ฑ
์ ๋ชฉ'] |
|
|
if title not in seen_titles: |
|
|
top_n_unique.append(row) |
|
|
seen_titles.add(title) |
|
|
|
|
|
return pd.DataFrame(top_n_unique)[['์ฑ
์ ๋ชฉ', column]] |
|
|
|
|
|
|
|
|
top_positive = get_top_n_unique(df, '๊ธ์ ', n=10) |
|
|
st.subheader("๊ธ์ ํ๋ฅ ์์ 10๊ฐ ์ฑ
") |
|
|
st.table(top_positive) |
|
|
|
|
|
|
|
|
top_negative = get_top_n_unique(df, '๋ถ์ ', n=10) |
|
|
st.subheader("๋ถ์ ํ๋ฅ ์์ 10๊ฐ ์ฑ
") |
|
|
st.table(top_negative) |
|
|
|
|
|
|
|
|
top_neutral = get_top_n_unique(df, '์ค๋ฆฝ', n=10) |
|
|
st.subheader("์ค๋ฆฝ ํ๋ฅ ์์ 10๊ฐ ์ฑ
") |
|
|
st.table(top_neutral) |
|
|
|