Skip to content

Instantly share code, notes, and snippets.

@fuwiak
Created September 24, 2019 16:45
Show Gist options
  • Save fuwiak/0f16771918b0d9ce782b3bcc0054e5dc to your computer and use it in GitHub Desktop.
Save fuwiak/0f16771918b0d9ce782b3bcc0054e5dc to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"#list of S&P\n",
"data = pd.read_html('https://en.wikipedia.org/wiki/List_of_S%26P_500_companies')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Symbol</th>\n",
" <th>Security</th>\n",
" <th>SEC filings</th>\n",
" <th>GICS Sector</th>\n",
" <th>GICS Sub Industry</th>\n",
" <th>Headquarters Location</th>\n",
" <th>Date first added</th>\n",
" <th>CIK</th>\n",
" <th>Founded</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td>0</td>\n",
" <td>MMM</td>\n",
" <td>3M Company</td>\n",
" <td>reports</td>\n",
" <td>Industrials</td>\n",
" <td>Industrial Conglomerates</td>\n",
" <td>St. Paul, Minnesota</td>\n",
" <td>NaN</td>\n",
" <td>66740</td>\n",
" <td>1902</td>\n",
" </tr>\n",
" <tr>\n",
" <td>1</td>\n",
" <td>ABT</td>\n",
" <td>Abbott Laboratories</td>\n",
" <td>reports</td>\n",
" <td>Health Care</td>\n",
" <td>Health Care Equipment</td>\n",
" <td>North Chicago, Illinois</td>\n",
" <td>1964-03-31</td>\n",
" <td>1800</td>\n",
" <td>1888</td>\n",
" </tr>\n",
" <tr>\n",
" <td>2</td>\n",
" <td>ABBV</td>\n",
" <td>AbbVie Inc.</td>\n",
" <td>reports</td>\n",
" <td>Health Care</td>\n",
" <td>Pharmaceuticals</td>\n",
" <td>North Chicago, Illinois</td>\n",
" <td>2012-12-31</td>\n",
" <td>1551152</td>\n",
" <td>2013 (1888)</td>\n",
" </tr>\n",
" <tr>\n",
" <td>3</td>\n",
" <td>ABMD</td>\n",
" <td>ABIOMED Inc</td>\n",
" <td>reports</td>\n",
" <td>Health Care</td>\n",
" <td>Health Care Equipment</td>\n",
" <td>Danvers, Massachusetts</td>\n",
" <td>2018-05-31</td>\n",
" <td>815094</td>\n",
" <td>1981</td>\n",
" </tr>\n",
" <tr>\n",
" <td>4</td>\n",
" <td>ACN</td>\n",
" <td>Accenture plc</td>\n",
" <td>reports</td>\n",
" <td>Information Technology</td>\n",
" <td>IT Consulting &amp; Other Services</td>\n",
" <td>Dublin, Ireland</td>\n",
" <td>2011-07-06</td>\n",
" <td>1467373</td>\n",
" <td>1989</td>\n",
" </tr>\n",
" <tr>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <td>500</td>\n",
" <td>XYL</td>\n",
" <td>Xylem Inc.</td>\n",
" <td>reports</td>\n",
" <td>Industrials</td>\n",
" <td>Industrial Machinery</td>\n",
" <td>White Plains, New York</td>\n",
" <td>2011-11-01</td>\n",
" <td>1524472</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <td>501</td>\n",
" <td>YUM</td>\n",
" <td>Yum! Brands Inc</td>\n",
" <td>reports</td>\n",
" <td>Consumer Discretionary</td>\n",
" <td>Restaurants</td>\n",
" <td>Louisville, Kentucky</td>\n",
" <td>1997-10-06</td>\n",
" <td>1041061</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <td>502</td>\n",
" <td>ZBH</td>\n",
" <td>Zimmer Biomet Holdings</td>\n",
" <td>reports</td>\n",
" <td>Health Care</td>\n",
" <td>Health Care Equipment</td>\n",
" <td>Warsaw, Indiana</td>\n",
" <td>2001-08-07</td>\n",
" <td>1136869</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <td>503</td>\n",
" <td>ZION</td>\n",
" <td>Zions Bancorp</td>\n",
" <td>reports</td>\n",
" <td>Financials</td>\n",
" <td>Regional Banks</td>\n",
" <td>Salt Lake City, Utah</td>\n",
" <td>2001-06-22</td>\n",
" <td>109380</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <td>504</td>\n",
" <td>ZTS</td>\n",
" <td>Zoetis</td>\n",
" <td>reports</td>\n",
" <td>Health Care</td>\n",
" <td>Pharmaceuticals</td>\n",
" <td>Florham Park, New Jersey</td>\n",
" <td>2013-06-21</td>\n",
" <td>1555280</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>505 rows × 9 columns</p>\n",
"</div>"
],
"text/plain": [
" Symbol Security SEC filings GICS Sector \\\n",
"0 MMM 3M Company reports Industrials \n",
"1 ABT Abbott Laboratories reports Health Care \n",
"2 ABBV AbbVie Inc. reports Health Care \n",
"3 ABMD ABIOMED Inc reports Health Care \n",
"4 ACN Accenture plc reports Information Technology \n",
".. ... ... ... ... \n",
"500 XYL Xylem Inc. reports Industrials \n",
"501 YUM Yum! Brands Inc reports Consumer Discretionary \n",
"502 ZBH Zimmer Biomet Holdings reports Health Care \n",
"503 ZION Zions Bancorp reports Financials \n",
"504 ZTS Zoetis reports Health Care \n",
"\n",
" GICS Sub Industry Headquarters Location \\\n",
"0 Industrial Conglomerates St. Paul, Minnesota \n",
"1 Health Care Equipment North Chicago, Illinois \n",
"2 Pharmaceuticals North Chicago, Illinois \n",
"3 Health Care Equipment Danvers, Massachusetts \n",
"4 IT Consulting & Other Services Dublin, Ireland \n",
".. ... ... \n",
"500 Industrial Machinery White Plains, New York \n",
"501 Restaurants Louisville, Kentucky \n",
"502 Health Care Equipment Warsaw, Indiana \n",
"503 Regional Banks Salt Lake City, Utah \n",
"504 Pharmaceuticals Florham Park, New Jersey \n",
"\n",
" Date first added CIK Founded \n",
"0 NaN 66740 1902 \n",
"1 1964-03-31 1800 1888 \n",
"2 2012-12-31 1551152 2013 (1888) \n",
"3 2018-05-31 815094 1981 \n",
"4 2011-07-06 1467373 1989 \n",
".. ... ... ... \n",
"500 2011-11-01 1524472 NaN \n",
"501 1997-10-06 1041061 NaN \n",
"502 2001-08-07 1136869 NaN \n",
"503 2001-06-22 109380 NaN \n",
"504 2013-06-21 1555280 NaN \n",
"\n",
"[505 rows x 9 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[0]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "env",
"language": "python",
"name": "env"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment