File size: 1,939 Bytes
be1ee7b 9e01318 be1ee7b 8d31a29 be1ee7b 9e01318 be1ee7b 9e01318 be1ee7b 9e01318 be1ee7b 9e01318 be1ee7b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
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("ํด๋น ์ฑ
์ ๋ชฉ์ ์ฐพ์ ์ ์์ต๋๋ค.")
# ๊ฐ ๊ฐ์ ์ ๋ํด ์์ 10๊ฐ์ ์ฑ
์ ๋ชฉ๊ณผ ํ๋ฅ ์ ์ถ์ถ
st.title("๊ฐ ๊ฐ์ ๋ณ ํ๋ฅ ์์ 10๊ฐ์ ์ฑ
")
# ํ๋ฅ ๋ฐ์ดํฐ๋ฅผ ๊ณต๋ฐฑ์ผ๋ก ๋ถ๋ฆฌํ์ฌ ๊ธ์ , ๋ถ์ , ์ค๋ฆฝ ์ด๋ก ๋ถ๋ฆฌ
df[['๊ธ์ ', '๋ถ์ ', '์ค๋ฆฝ']] = df['ํ๋ฅ '].str.strip('[]').str.split(expand=True).astype(float)
def get_top_n_unique(df, column, n=10):
# ์์ n๊ฐ์ ๋์๋ฅผ ์ถ์ถํ๋ ์ค๋ณต ์ ๊ฑฐ
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]]
# ๊ธ์ ํ๋ฅ ์์ 10๊ฐ
top_positive = get_top_n_unique(df, '๊ธ์ ', n=10)
st.subheader("๊ธ์ ํ๋ฅ ์์ 10๊ฐ ์ฑ
")
st.table(top_positive)
# ๋ถ์ ํ๋ฅ ์์ 10๊ฐ
top_negative = get_top_n_unique(df, '๋ถ์ ', n=10)
st.subheader("๋ถ์ ํ๋ฅ ์์ 10๊ฐ ์ฑ
")
st.table(top_negative)
# ์ค๋ฆฝ ํ๋ฅ ์์ 10๊ฐ
top_neutral = get_top_n_unique(df, '์ค๋ฆฝ', n=10)
st.subheader("์ค๋ฆฝ ํ๋ฅ ์์ 10๊ฐ ์ฑ
")
st.table(top_neutral)
|