sneves commited on
Commit
426a82e
·
verified ·
1 Parent(s): b5431ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -9
app.py CHANGED
@@ -28,19 +28,36 @@ with st.sidebar:
28
  selected_cik = st.selectbox('Select a company', cik_list, index=len(cik_list)-1)
29
  df_selected_cik = df[df.CIK == selected_cik]
30
 
31
- col = st.columns((1.5, 4.5, 2), gap='medium')
32
 
33
- with col[1]:
34
  st.markdown('#### ESG Scores')
35
 
36
- to_display = df[df['CIK'] == selected_cik]
37
  df_selected_cik['Year'] = df_selected_cik['Year'].astype('string')
38
  df_selected_cik.sort_values('Year', inplace=True)
39
  df_selected_cik.set_index('Year', inplace=True)
40
 
41
- lp = sns.lineplot(data=df_selected_cik[['e_score', 's_score', 'g_score']] )
42
- plt.xlabel('year')
43
- plt.ylabel('score')
44
- plt.legend(title='Legend', loc='upper left')
45
- st.pyplot(plt)
46
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  selected_cik = st.selectbox('Select a company', cik_list, index=len(cik_list)-1)
29
  df_selected_cik = df[df.CIK == selected_cik]
30
 
31
+ col1, col2 = st.columns(2)
32
 
33
+ with col1:
34
  st.markdown('#### ESG Scores')
35
 
 
36
  df_selected_cik['Year'] = df_selected_cik['Year'].astype('string')
37
  df_selected_cik.sort_values('Year', inplace=True)
38
  df_selected_cik.set_index('Year', inplace=True)
39
 
40
+ sns.lineplot(data=df_selected_cik[['e_score', 's_score', 'g_score']] )
41
+ plt_lp.xlabel('year')
42
+ plt_lp.ylabel('score')
43
+ plt_lp.legend(title='Legend', loc='upper left')
44
+ st.pyplot(plt_lp)
45
+
46
+ with col2:
47
+ st.markdown('### ESG Word Clouds')
48
+
49
+ wc_list = ['E_Text', 'S_Text', 'G_Text']
50
+
51
+ for x in wc_list:
52
+ row = to_display.loc[selected_year]
53
+ text = row.loc[x]
54
+ text = re.sub(r'[^A-Za-z\s]', '', text)
55
+ text = text.lower()
56
+ stopwords = set(STOPWORDS)
57
+ text = ' '.join(word for word in text.split() if word not in stopwords)
58
+
59
+ wordcloud = WordCloud(width=800, height=400, background_color='white').generate(text)
60
+
61
+ plt.figure(figsize=(10, 5))
62
+ plt.imshow(wordcloud, interpolation='bilinear')
63
+ plt.axis('off')