In this notebook we will download list of NIKKEI 225 stocks with pandas. To leverage power of pandas we will need to find the list of the NIKKEI 225 companies that is stored in html table on some website.

We chose to use unofficial source topforeignstocks.com because it contains components in html table. Hence downloading the data is much easier. Official source would be https://indexes.nikkei.co.jp/en/nkave/index/component?idx=nk225.

In [28]:
import pandas as pd

# There is only one table on the page
payload=pd.read_html('https://topforeignstocks.com/indices/the-components-of-the-nikkei-225-index/')

table_0 = payload[0]
df = table_0
In [29]:
df.head()
Out[29]:
S.No. Company Name Ticker Sector
0 1 ADVANTEST CORP 6857 Electric Appliances
1 2 AEON LTD 8267 Retail Trade
2 3 AGC INC 5201 Glass & Ceramics Products
3 4 AJINOMOTO INC 2802 Foods
4 5 ALPS ALPINE LTD 6770 Electric Appliances

Company tickers have numerical values (only cash has alphabetical ticker):

In [30]:
symbols = df['Ticker'].values.tolist()
print(symbols[:15])
['6857', '8267', '5201', '2802', '6770', '6113', '9202', '8304', '2502', '3407', '4503', '7832', '5108', '7751', 'MSJP']

Show related company names:

In [31]:
names = df['Company Name'].values.tolist()
print(names[:15])
['ADVANTEST CORP', 'AEON LTD', 'AGC INC', 'AJINOMOTO INC', 'ALPS ALPINE LTD', 'AMADA HOLDINGS LTD', 'ANA HOLDINGS INC', 'AOZORA BANK LTD', 'ASAHI GROUP HOLDINGS LTD', 'ASAHI KASEI CORP', 'ASTELLAS PHARMA INC', 'BANDAI NAMCO HOLDINGS INC', 'BRIDGESTONE CORP', 'CANON INC', 'CASH COLLATERAL JPY MSJP']
In [32]:
df
Out[32]:
S.No. Company Name Ticker Sector
0 1 ADVANTEST CORP 6857 Electric Appliances
1 2 AEON LTD 8267 Retail Trade
2 3 AGC INC 5201 Glass & Ceramics Products
3 4 AJINOMOTO INC 2802 Foods
4 5 ALPS ALPINE LTD 6770 Electric Appliances
5 6 AMADA HOLDINGS LTD 6113 Machinery
6 7 ANA HOLDINGS INC 9202 Air Transportation
7 8 AOZORA BANK LTD 8304 Banks
8 9 ASAHI GROUP HOLDINGS LTD 2502 Foods
9 10 ASAHI KASEI CORP 3407 Chemicals
10 11 ASTELLAS PHARMA INC 4503 Pharmaceutical
11 12 BANDAI NAMCO HOLDINGS INC 7832 Other Products
12 13 BRIDGESTONE CORP 5108 Rubber Products
13 14 CANON INC 7751 Electric Appliances
14 15 CASH COLLATERAL JPY MSJP MSJP Other
15 16 CASIO COMPUTER LTD 6952 Electric Appliances
16 17 CENTRAL JAPAN RAILWAY 9022 Land Transportation
17 18 CHIBA BANK LTD 8331 Banks
18 19 CHUBU ELECTRIC POWER INC 9502 Electric Power & Gas
19 20 CHUGAI PHARMACEUTICAL LTD 4519 Pharmaceutical
20 21 CITIZEN WATCH LTD 7762 Precision Instruments
21 22 COMSYS HOLDINGS CORP 1721 Construction
22 23 CONCORDIA FINANCIAL GROUP LTD 7186 Banks
23 24 CREDIT SAISON LTD 8253 Other Financing Business
24 25 CYBER AGENT INC 4751 Services
25 26 DAI NIPPON PRINTING LTD 7912 Other Products
26 27 DAI-ICHI LIFE HOLDINGS INC 8750 Insurance
27 28 DAIICHI SANKYO LTD 4568 Pharmaceutical
28 29 DAIKIN INDUSTRIES LTD 6367 Machinery
29 30 DAINIPPON SUMITOMO PHARMA LTD 4506 Pharmaceutical
... ... ... ... ...
197 198 TOHO (TOKYO) LTD 9602 Information & Communication
198 199 TOHO ZINC LTD 5707 Nonferrous Metal
199 200 TOKAI CARBON LTD 5301 Glass & Ceramics Products
200 201 TOKIO MARINE HOLDINGS INC 8766 Insurance
201 202 TOKUYAMA CORP 4043 Chemicals
202 203 TOKYO ELECTRIC POWER HOLDINGS INC 9501 Electric Power & Gas
203 204 TOKYO ELECTRON LTD 8035 Electric Appliances
204 205 TOKYO GAS LTD 9531 Electric Power & Gas
205 206 TOKYO TATEMONO LTD 8804 Real Estate ex REIT
206 207 TOKYU CORP 9005 Land Transportation
207 208 TOKYU FUDOSAN HOLDINGS CORP 3289 Real Estate ex REIT
208 209 TOPPAN PRINTING LTD 7911 Other Products
209 210 TORAY INDUSTRIES INC 3402 Textiles & Apparel
210 211 TOSOH CORP 4042 Chemicals
211 212 TOTO LTD 5332 Glass & Ceramics Products
212 213 TOYO SEIKAN GROUP HOLDINGS LTD 5901 Metal Products
213 214 TOYOBO LTD 3101 Textiles & Apparel
214 215 TOYOTA MOTOR CORP 7203 Transportation Equipment
215 216 TOYOTA TSUSHO CORP 8015 Wholesale Trade
216 217 TREND MICRO INC 4704 Information & Communication
217 218 UBE INDUSTRIES LTD 4208 Chemicals
218 219 UNITIKA LTD 3103 Textiles & Apparel
219 220 WEST JAPAN RAILWAY 9021 Land Transportation
220 221 YAMAHA CORP 7951 Other Products
221 222 YAMAHA MOTOR LTD 7272 Transportation Equipment
222 223 YAMATO HOLDINGS LTD 9064 Land Transportation
223 224 YASKAWA ELECTRIC CORP 6506 Electric Appliances
224 225 YOKOGAWA ELECTRIC CORP 6841 Electric Appliances
225 226 YOKOHAMA RUBBER LTD 5101 Rubber Products
226 227 Z HOLDINGS CORP 4689 Information & Communication

227 rows × 4 columns

Use below code to print the whole dataframe (or just save it to database or csv file):

In [33]:
#with pd.option_context('display.max_rows', None, 'display.max_columns', None):
#    print(df)