prototype / app.py
sneves's picture
Update app.py
a5a9cbd verified
raw
history blame
1.43 kB
import streamlit as st
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
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]
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)
ax = sns.lineplot(data=to_display[['e_score', 's_score', 'g_score']] )
ax.xlabel('year')
ax.ylabel('score')
ax.title('ESG scores for ')
ax.legend(title='Legend', loc='upper left')
return ax
col = st.columns((1.5, 4.5, 2), gap='medium')
with col[1]:
st.markdown('#### ESG Scores')
esgScoresPlot = make_esgScoresPlot(df, selected_cik)
esgScoresPlot