I am trying to get total esg scores from 2016-2021 for all companies in S&P500, but not every ticker has esg scores and some of them does not have data for 2016-2021.
My current code look like this:
import yesg
df = pd.DataFrame()
sp500 = pd.read_html('https://en.wikipedia.org/wiki/List_of_S%26P_500_companies')[0]
tickers = sp500['Symbol'].tolist()
for t in tickers:
data=yesg.get_historic_esg(t)['Total-Score']
df.append(data)
Please tell me how to get the data I need. Thanks in advance for your help.