Synapse_project / Climate_site /pages /3_Related_Companies.py
EmmaScharfmannBerkeley's picture
Upload 37 files
0b77e4b
import streamlit as st
st.set_page_config(page_title="Related Companies", page_icon="๐Ÿ›")
import pandas as pd
from python_scripts import functions
from python_scripts import functions_companies
@st.cache
def convert_df(df):
# IMPORTANT: Cache the conversion to prevent computation on every rerun
return df.to_csv()
header = st.container()
company_finder = st.container()
with company_finder:
st.markdown("# Related companies")
st.sidebar.header("Related companies")
st.write(
"""You can find the most related companies for each climate related IEA technology. Enjoy!"""
)
st.subheader("Select the technology you want to look at")
dic_technologies, dic_categories, list_categories_tech, list_technologies = functions_companies.finder()
list_technologies = [ ( list_categories_tech[i] , i ) for i in range(len(list_categories_tech)) ]
key0 = lambda t: t[0]
# Choose the category
tech_category = st.selectbox('Select a category',list_technologies, format_func = key0)
# After a selection is made the choices will update
# Choose the technology and number
technologies = dic_technologies[tech_category[0]]
technology = st.selectbox('Select a technology',technologies,format_func = key0)
size = st.slider('How many companies do you want?', 0, 50, 10)
st.subheader("Look at the related companies")
try:
reference_text, text1 , text2 = functions_companies.extract_quantitative_data_technology(
technologies = technology[0],
number_technology = technology[1],
)
st.write(f'<p style="color:Blue"> From IEA Website: <p style="color:Black"> <strong>Technology details:</strong> {reference_text}' , unsafe_allow_html = True)
st.write(f'<p style="color:Blue"> From IEA Website: <p style="color:Black"> <strong>Deployment target and Announced development target:</strong> {text1}' , unsafe_allow_html = True)
st.write(f'<p style="color:Blue"> From IEA Website: <p style="color:Black"> <strong>Announced cost reduction targets:</strong> {text2}' , unsafe_allow_html = True)
except:
st.write("No information about the technology")
#try:
if st.button('Get related companies'):
companies_ranked = functions_companies.related_VC_deals(
category = tech_category[1],
number_technology = technology[1],
size = size
)
st.dataframe(companies_ranked.style.format({"year_established": '{:.0f}'}))
csv = convert_df(companies_ranked)
st.download_button(
label="Download table as CSV",
data=csv,
file_name='companies.csv',
)
#except:
# st.write("No company found, try with other key words")