import streamlit as st import pandas as pd import matplotlib.pyplot as plt import pandas_bokeh # 글 쓰기(링크 삽입) st.title('VIETNAM DONGDAEMUN FOOOOOOOOOD!!!!!!!!!') st.header('Selection of Vietnamese Restaurants in Dongdaemun Area') st.subheader('Variety of dishes from different region in Vietnam, made affordable and delicious for local taste') st.subheader('Items such as Pho Soup, Bun Bo Hue, Cha Gio or Com Chien') st.write('''Write something here about the booming of Vietnamese Restaurant in Korea - particularly the fast growing food scene in Dongdaemun [푸드트럭](https://namu.wiki/w/%EB%B2%A0%ED%8A%B8%EB%82%A8%20%EC%9A%94%EB%A6%AC) .''' ) # 사진 삽입 st.image('/content/drive/MyDrive/DATA JOURNALISM/final - may31/final_image_2.jpg', caption='A Spread of Vietnamese Dishes You Might Be Able To Find') st.image('/content/drive/MyDrive/DATA JOURNALISM/final - may31/final_image_4.jpg', caption='A popular choice everywhere: Vietnamese Pho Soup') st.image('/content/drive/MyDrive/DATA JOURNALISM/final - may31/final_image_3.jpg', caption='Hidden Gem: Banh Xeo') st.header('Cheap and Delicious: One can find a variety of Vietnamese Restaurant in Dongdaemun Area') st.subheader('Hosting dishes from North to South Vietnam') st.subheader('The almost infinite choices will leave you looking for reviews!') st.write('''Before deciding on which dish you'd want ~ carefully browse through the Blog section for an intimate look at the local food joints''' ) # 데이터 보여주기 df_경희대맛집 = pd.read_excel('/content/drive/MyDrive/DATA JOURNALISM/final - may31/vietnam_food_dongdaemun_BLOGS.xlsx', index_col=0) st.write('We have narrowed down to 150 most relevant blogs!!', df_경희대맛집) df_경희대맛집_keyword = pd.read_excel('/content/drive/MyDrive/DATA JOURNALISM/final - may31/vietnam_food_KEYWORDS.xlsx', index_col=0) st.write('블로그 글에서 가장 많이 출현한 단어는 ~~~ 설명~~~', df_경희대맛집_keyword) # 워드클라우드 - WORDCLOUD st.write('주요 단어들을 워드클라우드로 보여주면 다음과 같다') st.image('/content/drive/MyDrive/DATA JOURNALISM/final - may31/final_WORDCLOUD.png') # 연결망 분석 - NETWORK st.write('''취재팀은 주요 단어들 간에 공동출현하는 관계를 바탕으로 의미연결망을 그려보았다. 분석결과, ~~설명~~''') st.image('/content/drive/MyDrive/DATA JOURNALISM/final - may31/final_NETWORK.png') #### The Section Below Is Extra Stuff We Gotta Think About ''' # df_교통사고 = pd.read_excel('/content/drive/MyDrive/2024_1_class/data_jour/data_traffic_accidents.xlsx', index_col=0) st.write('다음 데이터는 전국의 교통사고를 지역별로 집계한 것이다', df_교통사고) # 검색어 입력 받아 출력 query = st.text_input('이 곳에 지역명(시군구동읍면)을 입력하면 관련 데이터만 검색해 보여줍니다', key='region1_input') df_교통사고['select1']=df_교통사고['사고지역위치명'].apply(lambda x: 1 if query in x else 0) st.write('검색 결과:', df_교통사고[df_교통사고['select1']==1]) # 교통사고 유형과 연도에 따른 pivot table 보여주기 df_교통사고_pivot=df_교통사고.pivot_table(index='사고유형구분', columns='사고연도', values='사고건수', aggfunc='sum') df_교통사고_heatmap=df_교통사고_pivot.style.background_gradient(cmap='Oranges').format("{:.2f}") st.write('다음 표는 교통사고 건수를 유형과 연도에 따라 구분한 것이다', df_교통사고_heatmap) # 검색어 입력 받아 pivot table 출력 query_pivot = st.text_input('이 곳에 지역명(시군구)을 입력하면 관련 데이터만 검색해 보여줍니다', key='region2_input') df_교통사고['select2']=df_교통사고['사고지역위치명'].apply(lambda x: 1 if query_pivot in x else 0) df_교통사고_pivot_selected=df_교통사고[df_교통사고['select2']==1].pivot_table(index='사고유형구분', columns='사고연도', values='사고건수', aggfunc='sum') df_교통사고_heatmap_selected=df_교통사고_pivot_selected.style.background_gradient(cmap='Oranges').format("{:.2f}") st.write('검색 결과:', df_교통사고_heatmap_selected) # pandas_bokeh 그래프 보여주기 st.write('전국 교통사고 데이터에 따르면, 사고건수와 중상자수는 밀접한 관련을 맺고 있다. ~~~설명~~. *그래프 내 점에 커서를 대면 지역명이 나타난다') p_scatter = df_교통사고.plot_bokeh.scatter( x="사고건수", y="중상자수", title="사고건수와 중상자수", size=10, hovertool_string="""
위치:@{사고지역위치명}
""" ) st.bokeh_chart(p_scatter, use_container_width=True) # 선택한 조건에 따라 출력 option = st.selectbox('연도를 선택하면 해당 시기의 그래프를 보여줍니다', (2012, 2013, 2014, 2015, 2016, 2018, 2017, 2019, 2020, 2021), key='year_input') p_scatter_selected = df_교통사고[df_교통사고['사고연도']==option].plot_bokeh.scatter( x="사고건수", y="중상자수", title="사고건수와 중상자수", size=10, hovertool_string="""
위치:@{사고지역위치명}
""" ) st.write('검색 결과:') st.bokeh_chart(p_scatter_selected, use_container_width=True) '''