Skip to content

Instantly share code, notes, and snippets.

@ilonacodes
Created January 23, 2021 09:45
Show Gist options
  • Save ilonacodes/86cddd28309e64fdd868fad846a0485f to your computer and use it in GitHub Desktop.
Save ilonacodes/86cddd28309e64fdd868fad846a0485f to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
import pandas as pd
sp_table = pd.read_html('sp500.html')
sp = sp_table[0]
sp.to_csv('sp500-symbols.csv', columns=['Symbol'])
sp = pd.read_csv('sp500-symbols.csv')
sp_symbols = sp['Symbol'].to_list()
print(sp_symbols)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment