prototype / app.py
sneves's picture
Update app.py
72269cb verified
raw
history blame
1.45 kB
import streamlit as st
import pandas as pd
from wordcloud import WordCloud
import re
from wordcloud import STOPWORDS
st.set_page_config(
page_title="ESG for All",
layout="wide",
initial_sidebar_state="expanded")
df = pd.read_csv('all_filings_esg_text.csv')
with st.sidebar:
st.title('ESG for All')
year_list = list(df.Year.unique())[::-1]
year_list = sorted(year_list)
selected_year = st.selectbox('Select a year', year_list, index=len(year_list)-1)
df_selected_year = df[df.Year == selected_year]
cik_list = list(df.CIK.unique())[::-1]
cik_list = sorted(cik_list)
selected_cik = st.selectbox('Select a company', cik_list, index=len(cik_list)-1)
df_selected_cik = df[df.CIK == selected_cik]
color_theme_list = ['blues', 'cividis', 'greens', 'inferno', 'magma', 'plasma', 'reds', 'rainbow', 'turbo', 'viridis']
selected_color_theme = st.selectbox('Select a color theme', color_theme_list)
def make_esgScoresPlot(df, cik):
to_display = df[df['CIK'] == cik]
to_display['Year'] = to_display['Year'].astype('string')
to_display.sort_values('Year', inplace=True)
to_display.set_index('Year', inplace=True)
return st.linechart(data=to_display[['e_score', 's_score', 'g_score']])
col = st.columns((1.5, 4.5, 2), gap='medium')
with col[1]:
st.markdown('#### ESG Scores')
esgScoresPlot = make_esgScoresPlot(df, selected_cik)
esgScoresPlot