diff --git a/phase3 Dashboard/app.py b/phase3 Dashboard/app.py index 6af1be3..bae121f 100644 --- a/phase3 Dashboard/app.py +++ b/phase3 Dashboard/app.py @@ -1,12 +1,11 @@ import streamlit as st from streamlit_extras.let_it_rain import rain from PIL import Image -import matplotlib.pyplot as plt image = Image.open('attrs/logo.png') st.image(image) rain( - emoji="πŸ“™", + emoji="πŸ“—", font_size=30, falling_speed=9, animation_length="infinite", diff --git a/phase3 Dashboard/model/__init__.py b/phase3 Dashboard/model/__init__.py index 1fbea4a..8346b49 100644 --- a/phase3 Dashboard/model/__init__.py +++ b/phase3 Dashboard/model/__init__.py @@ -168,57 +168,66 @@ def get_best_books_by_budget(mysql: MySQLConnection, budget) -> pd.DataFrame: select book_detail.book_id,\ book_detail.Persian_title,\ book_detail.English_title,\ - publisher_id,\ - max(price_history.date) as last_update,\ - score,\ - (price * (100 - price_history.discount) / 100) as after_discount,\ - sum((price * (100 - price_history.discount) / 100)) over (order by score\ - desc, price) as sumofprice\ + publisher_id,score,\ + (prices_tbl.price * (100 - prices_tbl.discount) / 100) as after_discount,\ + prices_tbl.date\ from book_detail\ - inner join price_history\ - on book_detail.book_id = price_history.book_id\ + inner join (SELECT book_id, date, price, discount\ + FROM price_history\ + WHERE (book_id, date) IN (SELECT book_id, MAX(date)\ + FROM price_history\ + GROUP BY book_id)) as prices_tbl\ + on prices_tbl.book_id = book_detail.book_id\ where book_detail.stock_status = ' Ω…ΩˆΨ¬ΩˆΨ― '\ - and (price * (100 - price_history.discount) / 100)<={budget}\ - group by book_detail.book_id\ - order by score desc, price) as t where sumofprice<={budget}" + and (prices_tbl.price * (100 - prices_tbl.discount) / 100) <= {budget}\ + order by score desc, after_discount) as inner_tbl) as outer_tbl\ + where sumofprice <= {budget}" return pandas_sql(mysql, query) -def get_most_profitable_books_by_budget(mysql:MySQLConnection,budget) ->pd.DataFrame: - query=f"select * from (\ + +def get_most_profitable_books_by_budget(mysql: MySQLConnection, budget) -> pd.DataFrame: + query = f"select * from (\ select book_detail.book_id,\ book_detail.Persian_title,\ book_detail.English_title,\ - max(price_history.date) as last_update,\ - edition,\ - publisher_id,\ - (price * (100 - price_history.discount) / 100) as after_discount,\ - sum((price * (100 - price_history.discount) / 100)) over (order by edition\ - desc, price) as sumofprice\ + publisher_id,edition,\ + (prices_tbl.price * (100 - prices_tbl.discount) / 100) as after_discount,\ + prices_tbl.date\ from book_detail\ - inner join price_history\ - on book_detail.book_id = price_history.book_id\ + inner join (SELECT book_id, date, price, discount\ + FROM price_history\ + WHERE (book_id, date) IN (SELECT book_id, MAX(date)\ + FROM price_history\ + GROUP BY book_id)) as prices_tbl\ + on prices_tbl.book_id = book_detail.book_id\ where book_detail.stock_status = ' Ω…ΩˆΨ¬ΩˆΨ― '\ - and (price * (100 - price_history.discount) / 100)<={budget}\ - group by book_detail.book_id\ - order by edition desc, price) as t where sumofprice<={budget}" - return pandas_sql(mysql,query) + and (prices_tbl.price * (100 - prices_tbl.discount) / 100) <= {budget}\ + order by edition desc, after_discount) as inner_tbl) as outer_tbl\ + where sumofprice <= {budget}" + return pandas_sql(mysql, query) + -def get_most_books_by_budget(mysql:MySQLConnection,budget) ->pd.DataFrame: - query=f"select * from (\ +def get_most_books_by_budget(mysql: MySQLConnection, budget) -> pd.DataFrame: + query = f"select * from (\ select book_detail.book_id,\ book_detail.Persian_title,\ + book_detail.English_title,\ publisher_id,\ - max(price_history.date) as last_update,\ - (price * (100 - price_history.discount) / 100) as after_discount,\ - sum((price * (100 - price_history.discount) / 100)) over (order by price) as sumofprice\ + (prices_tbl.price * (100 - prices_tbl.discount) / 100) as after_discount,\ + prices_tbl.date\ from book_detail\ - inner join price_history\ - on book_detail.book_id = price_history.book_id\ + inner join (SELECT book_id, date, price, discount\ + FROM price_history\ + WHERE (book_id, date) IN (SELECT book_id, MAX(date)\ + FROM price_history\ + GROUP BY book_id)) as prices_tbl\ + on prices_tbl.book_id = book_detail.book_id\ where book_detail.stock_status = ' Ω…ΩˆΨ¬ΩˆΨ― '\ - and (price * (100 - price_history.discount) / 100)<={budget}\ - group by book_detail.book_id\ - order by price) as t where sumofprice<={budget}" - return pandas_sql(mysql,query) + and (prices_tbl.price * (100 - prices_tbl.discount) / 100) <= {budget}\ + order by after_discount) as inner_tbl) as outer_tbl\ + where sumofprice <= {budget}" + return pandas_sql(mysql, query) + def get_unique_books(mysql: MySQLConnection, number) -> pd.DataFrame: query = f"select book_id,Persian_title,English_title,count(distinct rewards.reward) as award\ @@ -227,42 +236,50 @@ def get_unique_books(mysql: MySQLConnection, number) -> pd.DataFrame: group by rewards.site_id\ order by award desc\ limit {number}" - return pandas_sql(mysql,query) -def get_most_veneration_book(mysql:MySQLConnection,num) ->pd.DataFrame: - query=f'select book_detail.Persian_title,book_detail.English_title,\ + return pandas_sql(mysql, query) + + +def get_most_veneration_book(mysql: MySQLConnection, num) -> pd.DataFrame: + query = f'select book_detail.Persian_title,book_detail.English_title,\ count(distinct veneration.prise_writer) as count_comment\ from book_detail\ inner join veneration on veneration.site_id = book_detail.site_id\ group by veneration.site_id\ order by count_comment desc\ limit {num}' - return pandas_sql(mysql,query) -def get_all_books_with_tags(mysql:MySQLConnection)->pd.DataFrame: - query='select book_tag.site_id, tags.name\ + return pandas_sql(mysql, query) + + +def get_all_books_with_tags(mysql: MySQLConnection) -> pd.DataFrame: + query = 'select book_tag.site_id, tags.name\ from (select site_id\ from book_tag\ inner join tags on tags.id = book_tag.tag_id) as tbl\ inner join book_tag on tbl.site_id = book_tag.site_id\ inner join tags on book_tag.tag_id = tags.id' - return pandas_sql(mysql,query) -def get_translators_name(mysql:MySQLConnection)->list[str]: - query='select distinct name\ + return pandas_sql(mysql, query) + + +def get_translators_name(mysql: MySQLConnection) -> list[str]: + query = 'select distinct name\ from translator\ inner join translator_page on translator.translator_id = translator_page.translator_id' - return list(pandas_sql(mysql,query).name) + return list(pandas_sql(mysql, query).name) + -def get_all_books_translators(mysql:MySQLConnection)->pd.DataFrame: - query="select book_detail.book_id, translator_page.name\ +def get_all_books_translators(mysql: MySQLConnection) -> pd.DataFrame: + query = "select book_detail.book_id, translator_page.name\ from (select book_id\ from translator\ inner join translator_page on translator_page.translator_id = translator.translator_id) as tbl\ inner join book_detail on book_detail.book_id = tbl.book_id\ inner join translator on book_detail.book_id = translator.book_id\ inner join translator_page on translator_page.translator_id = translator.translator_id" - return pandas_sql(mysql,query) + return pandas_sql(mysql, query) + -def get_number_of_books_published_by_pubs(mysql:MySQLConnection)->pd.DataFrame: - query='SELECT p1.name AS publisher1, p2.name AS publisher2,COUNT(*) AS book_count\ +def get_number_of_books_published_by_pubs(mysql: MySQLConnection) -> pd.DataFrame: + query = 'SELECT p1.name AS publisher1, p2.name AS publisher2,COUNT(*) AS book_count\ FROM book_detail AS bd1\ INNER JOIN book_detail AS bd2 ON bd1.English_title = bd2.English_title AND bd1.publisher_id < bd2.publisher_id\ INNER JOIN publisher AS p1 ON bd1.publisher_id = p1.id\ @@ -271,4 +288,53 @@ def get_number_of_books_published_by_pubs(mysql:MySQLConnection)->pd.DataFrame: HAVING book_count >= 1\ ORDER BY book_count DESC\ limit 40;' - return pandas_sql(mysql,query) \ No newline at end of file + return pandas_sql(mysql, query) + + +def get_all_books_writers(mysql: MySQLConnection) -> pd.DataFrame: + query = "select book_detail.book_id, writer_page.name\ + from (select site_id\ + from writer\ + inner join writer_page on writer_page.writer_id = writer.writer_id ) as tbl\ + inner join book_detail on book_detail.site_id = tbl.site_id\ + inner join writer on book_detail.site_id= writer.site_id\ + inner join writer_page on writer_page.writer_id = writer.writer_id" + return pandas_sql(mysql, query) + + +def get_publisher_translator(mysql: MySQLConnection) -> pd.DataFrame: + query = "SELECT p.name AS publisher_name, tp.name AS translator_name, MAX(translation_count) AS book_count\ + FROM publisher AS p\ + JOIN book_detail AS bd ON p.id = bd.publisher_id\ + JOIN translator AS t ON bd.book_id = t.book_id\ + JOIN translator_page AS tp ON t.translator_id = tp.translator_id\ + JOIN(SELECT p.id AS publisher_id, t.name AS translator_name, COUNT(*) AS translation_count\ + FROM publisher AS p\ + JOIN book_detail AS bd ON p.id = bd.publisher_id\ + JOIN translator AS tr ON bd.book_id = tr.book_id\ + JOIN translator_page AS t ON tr.translator_id = t.translator_id\ + GROUP BY p.id, t.name) AS translator_counts ON p.id = translator_counts.publisher_id\ + AND tp.name = translator_counts.translator_name\ + GROUP BY p.name\ + ORDER BY book_count desc" + return pandas_sql(mysql, query) + + +def get_publisher_genres(mysql: MySQLConnection) -> pd.DataFrame: + query = "SELECT t.name AS genre_name,p.name AS best_publisher_name,MAX(book_count) AS max_book_count\ + FROM tags AS t\ + JOIN book_tag AS bt ON t.id = bt.tag_id\ + JOIN book_summary AS bs ON bt.site_id = bs.site_id\ + JOIN book_detail AS bd ON bs.site_id = bd.site_id\ + JOIN publisher AS p ON bd.publisher_id = p.id\ + JOIN(SELECT t.id AS tag_id, p.id AS publisher_id,COUNT(*) AS book_count,ROW_NUMBER() OVER (PARTITION BY t.id ORDER BY COUNT(*) DESC) AS row_num\ + FROM tags AS t\ + JOIN book_tag AS bt ON t.id = bt.tag_id\ + JOIN book_summary AS bs ON bt.site_id = bs.site_id\ + JOIN book_detail AS bd ON bs.site_id = bd.site_id\ + JOIN publisher AS p ON bd.publisher_id = p.id\ + GROUP BY t.id, p.id\ + ) AS max_counts ON t.id = max_counts.tag_id AND p.id = max_counts.publisher_id\ + GROUP BY t.name\ + limit 20;" + return pandas_sql(mysql, query) diff --git "a/phase3 Dashboard/pages/1\360\237\222\273_table_filtering.py" "b/phase3 Dashboard/pages/1\360\237\222\273_table_filtering.py" index 83225d9..4c15793 100644 --- "a/phase3 Dashboard/pages/1\360\237\222\273_table_filtering.py" +++ "b/phase3 Dashboard/pages/1\360\237\222\273_table_filtering.py" @@ -1,5 +1,6 @@ import streamlit as st from model import * +import pandas as pd st.markdown("

πŸ’» Table Filtering

", unsafe_allow_html=True) try: @@ -44,6 +45,7 @@ def prepare_df(): #writer filtering writers_df=get_writer_df(mysqldb) writers_list=writers_df['name'].drop_duplicates().to_list() + all_books_writers=get_all_books_writers(mysqldb) #translator filtering translator_list=get_translators_name(mysqldb) all_books_translators=get_all_books_translators(mysqldb) @@ -58,13 +60,13 @@ def prepare_df(): all_books_with_tags_df=get_all_books_with_tags(mysqldb) return [price_list,tags_list,publishers_list,\ writers_list,edition_list,language_list,persian_title_list,\ - english_title_list,stock_status_list,score_list,all_books_with_tags_df,translator_list,all_books_translators] + english_title_list,stock_status_list,score_list,all_books_with_tags_df,translator_list,all_books_translators, all_books_writers] set_font() price_list,tags_list,publishers_list,writers_list\ ,edition_list,language_list,persian_title_list,\ -english_title_list,stock_status_list,score_list,all_books_tags_df,translator_list,all_books_translators=prepare_df() +english_title_list,stock_status_list,score_list,all_books_tags_df,translator_list,all_books_translators, all_books_writers=prepare_df() st.sidebar.markdown("Choose your filter: ") persian_title_box=st.sidebar.multiselect('Book Title',options=persian_title_list,default=None) tags_box=st.sidebar.multiselect('book_tags',options=tags_list,default=tags_list[0]) @@ -83,16 +85,14 @@ def prepare_df(): query='select book_detail.site_id,book_detail.book_id,Persian_title,English_title,score,edition,\ solar_publication_year,ad_publication_year,book_language,stock_status,price,\ - discount,publisher.name as publisher,writer_page.name as writer,book_detail.page_number as page_number\ + discount,publisher.name as publisher,book_detail.page_number as page_number\ from book_detail\ join price_history on price_history.book_id=book_detail.book_id\ join publisher on publisher.id=book_detail.publisher_id\ join book_summary on book_summary.site_id = book_detail.site_id\ - join writer on writer.site_id=book_summary.site_id\ - join writer_page on writer.writer_id = writer_page.writer_id\ where price_history.price between '+str(price_range[0]) +' and '+str(price_range[1])\ +' and book_detail.page_number between '+str(page_number_range[0]) +' and '+str(page_number_range[1]) - + if len(tags_box)!=0: book_tags_query='select book_tag.site_id, tags.name\ from (select site_id\ @@ -111,7 +111,7 @@ def prepare_df(): from (select book_id\ from translator\ inner join translator_page on translator_page.translator_id = translator.translator_id\ - where translator_page.name in in("+str(translator_box).replace('[','').replace(']','')+")) as tbl\ + where translator_page.name in ("+str(translator_box).replace('[','').replace(']','')+")) as tbl\ inner join book_detail on book_detail.book_id = tbl.book_id\ inner join translator on book_detail.book_id = translator.book_id\ inner join translator_page on translator_page.translator_id = translator.translator_id" @@ -119,6 +119,20 @@ def prepare_df(): else: book_translator_df=all_books_translators.copy() book_translator_df.rename(columns={'name':'translator'},inplace=True) + + if len(writers_box)!=0: + book_writer_query="select book_detail.book_id, writer_page.name\ + from (select site_id\ + from writer\ + inner join writer_page on writer_page.writer_id = writer.writer_id\ + where writer_page.name in ("+str(writers_box).replace('[','').replace(']','')+")) as tbl\ + inner join book_detail on book_detail.site_id = tbl.site_id\ + inner join writer on book_detail.site_id= writer.site_id\ + inner join writer_page on writer_page.writer_id = writer.writer_id" + book_writer_df=get_search_result(mysqldb,book_writer_query) + else: + book_writer_df=all_books_writers.copy() + book_writer_df.rename(columns={'name':'writer'},inplace=True) if len(persian_title_box)!=0: @@ -132,13 +146,17 @@ def prepare_df(): query+=' and stock_status in('+str(stock_status_box).replace('[','').replace(']','')+')' if len(publishers_box)!=0: query+=' and publisher.name in('+str(publishers_box).replace('[','').replace(']','')+')' - if len(writers_box)!=0: - query+=' and writer_page.name in('+str(writers_box).replace('[','').replace(']','')+')' searched_df=get_search_result(mysqldb,query) + searched_df=pd.merge(book_tags_df,searched_df,how='inner') - searched_df=pd.merge(searched_df,book_translator_df,how='inner') - + merge_with_translator=pd.merge(searched_df,book_translator_df,how='inner') + if merge_with_translator.empty == False: + searched_df = merge_with_translator.copy() + merge_with_writer=pd.merge(searched_df,book_writer_df,how='inner') + if merge_with_writer.empty == False: + searched_df = merge_with_writer.copy() + grouped=searched_df.groupby('book_id') all_book_list=[] @@ -164,29 +182,38 @@ def prepare_df(): # Loop through each row in the group for index, row in group.iterrows(): this_book_tag.append(row['tag_name']) - this_book_writer.append(row['writer']) - this_book_translator.append(row['translator']) + if 'writer' in group.columns: + this_book_writer.append(row['writer']) + if 'translator' in group.columns: + this_book_translator.append(row['translator']) book_dict['tags']=this_book_tag book_dict['writer']=list(set(this_book_writer)) book_dict['translator']=list(set(this_book_translator)) all_book_list.append(book_dict.copy()) # st.write(book_dict) - + if(len(all_book_list)) == 0: st.markdown(''':rainbow[***No Book was Found with this Features***]''') else: for book in all_book_list: + st.subheader(book['english_title']) col1, col2 = st.columns(2) + writer_set = set(book['writer']) + writer_lst = list(writer_set) + writer_str = '' + for wr in range(len(writer_lst)-1): + writer_str += writer_lst[wr] + writer_str += ', ' + writer_str += writer_lst[-1] with col1: - st.header(book['english_title']) - st.subheader(book['persian_title']) - st.write('Writer: ', book['writer'][0]) + st.markdown(f"**{book['persian_title']}**") + st.write('Writer: ', writer_str) st.write('Translator: ',str(book['translator']).replace('[','').replace(']','').replace("'",'')) st.write('Publisher: ', book['publisher']) st.write(book['score'], f"{show_stars(book['score'])}") - - ind_lst = ['','','','', 'Publication year:','Publication year:', 'Stock Status:', 'Price:', 'Discount:'] - val_lst = ['','','','', book['solar_publication_year'], book['ad_publication_year'], + + ind_lst = ['Publication year:','Publication year:', 'Stock Status:', 'Price:', 'Discount:'] + val_lst = [book['solar_publication_year'], book['ad_publication_year'], book['status'], str(book['price'])+' toman', str(book['discount'])+'%'] df = pd.DataFrame({'ind': ind_lst, 'val': val_lst}) with col2: diff --git "a/phase3 Dashboard/pages/1\360\237\223\212_Statistical_analysis.py" "b/phase3 Dashboard/pages/1\360\237\223\211_Statistical_analysis.py" similarity index 98% rename from "phase3 Dashboard/pages/1\360\237\223\212_Statistical_analysis.py" rename to "phase3 Dashboard/pages/1\360\237\223\211_Statistical_analysis.py" index 3d13fb8..62771a4 100644 --- "a/phase3 Dashboard/pages/1\360\237\223\212_Statistical_analysis.py" +++ "b/phase3 Dashboard/pages/1\360\237\223\211_Statistical_analysis.py" @@ -39,7 +39,7 @@ def prepare_data(_mysqldb: MySQLConnection): return book_tags_df, publisher_book_df, books_by_solar_year, books_by_ad_year, top_10_writer_by_book_count, top_10_translator_by_book_count -st.set_page_config(page_icon='πŸ“Š', page_title='statistical analysis', layout='wide') +st.set_page_config(page_icon='πŸ“‰', page_title='statistical analysis', layout='wide') st.markdown("

πŸ“Š Statistical analysis

", unsafe_allow_html=True) set_font() diff --git "a/phase3 Dashboard/pages/2\360\237\223\210_Statistical_analysis.py" "b/phase3 Dashboard/pages/2\360\237\223\210_Statistical_analysis.py" index 7ed1080..447431a 100644 --- "a/phase3 Dashboard/pages/2\360\237\223\210_Statistical_analysis.py" +++ "b/phase3 Dashboard/pages/2\360\237\223\210_Statistical_analysis.py" @@ -39,7 +39,7 @@ def prepare_data(_mysqldb:MySQLConnection): page_publication_rel,price_publication_rel,price_score_rel,books_by_format=prepare_data(mysqldb) set_font() -lottie_chart = json.load(open( "analysis2.json")) +lottie_chart = json.load(open("analysis2.json")) col1,col2,col3 = st.columns([1,2,1]) with col2: st_lottie(lottie_chart,speed=1, loop=True, quality="medium", width=700,height=200) diff --git "a/phase3 Dashboard/pages/3\360\237\223\212_Further_analysis.py" "b/phase3 Dashboard/pages/3\360\237\223\212_Further_analysis.py" new file mode 100644 index 0000000..3aa7a02 --- /dev/null +++ "b/phase3 Dashboard/pages/3\360\237\223\212_Further_analysis.py" @@ -0,0 +1,65 @@ +from model import * +import streamlit as st +from streamlit_lottie import st_lottie +import json +import plotly.express as px +from pyvis.network import Network + +st.set_page_config(page_icon='πŸ“Š', page_title='Further Analysis', layout='wide') +st.markdown("

πŸ“Š Further Analysis

", unsafe_allow_html=True) + + +def set_connection(): + try: + mysqldb = get_connection() + except: + st.error("Make Sure Database is up & Running", icon="🚨") + st.stop() + return mysqldb + + +mysqldb = set_connection() + +st.markdown(f""" +

Lets have a closer look on the Data...

+ """, unsafe_allow_html=True) + + +@st.cache_data +def prepare_data(_mysqldb: MySQLConnection): + publisher_translator = get_publisher_translator(_mysqldb) + publisher_genres = get_publisher_genres(_mysqldb) + return publisher_translator, publisher_genres + + +publisher_translator, publisher_genres = prepare_data(mysqldb) + +st.markdown(f"""

Price scatter chart based on book score

+ """, unsafe_allow_html=True) + +fig1 = px.bar(publisher_translator, x='publisher_name', y='book_count', + hover_data=['translator_name'], color='book_count', + labels={'book_count': 'Book Count', 'publisher_name': 'Publisher Name'}, + title="Publisher Translator Book Count") +st.plotly_chart(fig1, use_container_width=True) + +fig2 = px.bar(publisher_genres, x='genre_name', y='max_book_count', + hover_data=['best_publisher_name'], color='max_book_count', + labels={'max_book_count': 'Max Book Count', 'genre_name': 'Genre Name'}, + title="Publisher Genres Max Book Count") +st.plotly_chart(fig2) + +st.markdown("
Publisher's Same Books Correlation
", unsafe_allow_html=True) +df = get_number_of_books_published_by_pubs(mysqldb) + +net = Network() +actors1 = list(df['publisher1']) +nodes = set(list(df['publisher1']) + list(df['publisher2'])) +title = 'publisher\'s same books correlation' +net.add_nodes(nodes) +for index, row in df.iterrows(): + net.add_edge(row['publisher1'], row['publisher2'], value=row['book_count'], title=row['book_count']) +net.save_graph('network.html') +with open("network.html", "r") as f: + network_html = f.read() +st.components.v1.html(network_html, width=800, height=600) diff --git "a/phase3 Dashboard/pages/4\360\237\223\242_publisher.py" "b/phase3 Dashboard/pages/4\360\237\223\242_publisher.py" deleted file mode 100644 index 870a7f6..0000000 --- "a/phase3 Dashboard/pages/4\360\237\223\242_publisher.py" +++ /dev/null @@ -1,55 +0,0 @@ -import streamlit as st -from model import * -from matplotlib import pyplot as plt -import numpy as np -# from wordcloud import WordCloud - -st.set_page_config(page_icon='πŸ’―',page_title='extera feature') -st.markdown("

πŸ“’ publishers

", unsafe_allow_html=True) -try: - mysqldb = get_connection() -except: - st.error("Make Sure Database is up & Running", icon="🚨") - st.stop() - -# @st.cache_data -# def prepare(): -# book_summary_df=get_book_summary(mysqldb) -# book_title_list=book_summary_df['Persian_title'].drop_duplicates().to_list() -# return book_summary_df,book_title_list - - - -# book_summary_df,book_title_list=prepare() -# Create some sample text -# font_path = "C:\\Users\\Asus\\Downloads\\chocolatier_artisanal\\Chocolatier Artisanal.ttf" -# translator = Translator(from_lang="fa", to_lang="en") -# st.markdown("

β˜οΈπŸ“—Book's word cloud

", unsafe_allow_html=True) -# book_title= st.selectbox("Select a book", book_title_list) -# if book_title is None: -# st.write('select') -# else: -# book_summary=book_summary_df[book_summary_df['Persian_title']==book_title]['summary'] -# # st.write(book_summary.iloc[0]) -# # translation=translator.translate(book_summary.iloc[0]) -# # st.write(translation) -# wordcloud = WordCloud(width=800, height=400, background_color='white' -# )\ -# .generate(book_summary.iloc[0]) -# # st.markdown(f'
{wordcloud.to_html()}
', unsafe_allow_html=True) -# st.image(wordcloud.to_image()) - -st.markdown("
publisher's same books network graph
", unsafe_allow_html=True) -df=get_number_of_books_published_by_pubs(mysqldb) - -from pyvis.network import Network -net = Network() -actors1=list(df['publisher1']) -nodes=set(list(df['publisher1'])+list(df['publisher2'])) -net.add_nodes(nodes) -for index,row in df.iterrows(): - net.add_edge(row['publisher1'], row['publisher2'], value=row['book_count'],title=row['book_count']) -net.show('network.html') -with open("network.html", "r") as f: - network_html = f.read() -st.components.v1.html(network_html, width=800, height=600) \ No newline at end of file diff --git "a/phase3 Dashboard/pages/3\360\237\247\256_store.py" "b/phase3 Dashboard/pages/4\360\237\247\256_store.py" similarity index 95% rename from "phase3 Dashboard/pages/3\360\237\247\256_store.py" rename to "phase3 Dashboard/pages/4\360\237\247\256_store.py" index 0fdabe7..ddc7f2c 100644 --- "a/phase3 Dashboard/pages/3\360\237\247\256_store.py" +++ "b/phase3 Dashboard/pages/4\360\237\247\256_store.py" @@ -18,7 +18,8 @@ def set_connection():

Start your career as a book seller here...

""",unsafe_allow_html=True) # lottie_url_flower = "../qwPu6tqAZO.json" -lottie_shop = json.load(open( "bookshop.json")) +lottie_shop = json.load(open("../bookshop.json")) + col1,col2,col3 = st.columns([1,2,1]) with col2: st_lottie(lottie_shop,speed=5, loop=True, quality="medium", width=400,height=200) @@ -44,7 +45,7 @@ def prepare_df(_mysqldb:MySQLConnection): else: afforadble_books=get_best_books_by_budget(mysqldb,budget) st.dataframe(afforadble_books) -st.markdown('You can find unique books based on ypur desired feature') +st.markdown('You can find unique books based on your desired feature') unique = st.number_input( "Enter number of books you want hereπŸ‘‡" , min_value=1, step=1) criteria_unique = st.radio( "**What's your purpose**", diff --git a/phase3 Dashboard/pages/extera.py b/phase3 Dashboard/pages/extra.py similarity index 100% rename from phase3 Dashboard/pages/extera.py rename to phase3 Dashboard/pages/extra.py