# Get Data

### Country

```python
import pandas as pd
import pandas_datareader as pdr
from pandas_datareader import wb

countries = pdr.wb.get_countries()
countries
```

```
iso3c iso2c         name                      region  \
0   ABW    AW        Aruba  Latin America & Caribbean    
1   AFG    AF  Afghanistan                  South Asia   
2   AFR    A9       Africa                  Aggregates   
3   AGO    AO       Angola         Sub-Saharan Africa    
4   ALB    AL      Albania       Europe & Central Asia   

                                     adminregion          incomeLevel  \
0                                                         High income   
1                                     South Asia           Low income   
2                                                          Aggregates   
3     Sub-Saharan Africa (excluding high income)  Lower middle income   
4  Europe & Central Asia (excluding high income)  Upper middle income   

      lendingType capitalCity  longitude  latitude  
0  Not classified  Oranjestad   -70.0167  12.51670  
1             IDA       Kabul    69.1761  34.52280  
2      Aggregates                    NaN       NaN  
3            IBRD      Luanda    13.2420  -8.81155  
4            IBRD      Tirane    19.8172  41.33170  
```

### Ticker lists <a href="#ticker-lists" id="ticker-lists"></a>

```python
import yahoo_fin.stock_info as si

# get list of Down Jones Stocks
dow_list = tickers_dow()
dow_list 

# Output

['AAPL', 'AXP', 'BA', 'CAT', 'CSCO', 'CVX', 'DIS', 'DOW', 'GS',
 'HD', 'IBM', 'INTC', 'JNJ', 'JPM', 'KO', 'MCD', 'MMM', 'MRK',
 'MSFT', 'NKE', 'PFE', 'PG', 'RTX', 'TRV', 'UNH', 'V', 'VZ',
 'WBA', 'WMT', 'XOM']
 
 # get list of NASDAQ stocks
nasdaq_list = tickers_nasdaq()
nasdaq_list

# Output (Example)
['AACQU', 'AAL', 'AAME', 'AAO', 'AAOI', 'AAPL', 'AAWW',
 'AAX', 'AAXJ', 'ABEO', 'ABIO', 'ABMD', 'ABTX']
```

### Stock Info & Stat

```python
import yahoo_fin.stock_info as si

get_quote_table('ptt.bk')
```

```python
# Output
{'1y Target Est': 57.51,
 '52 Week Range': '23.60 - 47.75',
 'Ask': '38.75 x 0',
 'Avg. Volume': 63144106.0,
 'Beta (5Y Monthly)': 1.01,
 'Bid': '38.50 x 0',
 "Day's Range": '38.50 - 39.25',
 'EPS (TTM)': 2.13,
 'Earnings Date': 'Aug 11, 2020',
 'Ex-Dividend Date': 'Mar 04, 2020',
 'Forward Dividend & Yield': '2.00 (5.19%)',
 'Market Cap': '1.1T',
 'Open': 39.0,
 'PE Ratio (TTM)': 18.08,
 'Previous Close': 39.75,
 'Quote Price': 38.5,
 'Volume': 42731400.0}
```

```python
# yfinance
import yfinance as yf

data = yf.Ticker("ptt.bk")
data.info
```

```python
# Output
{'language': 'en-US',
 'region': 'US',
 'quoteType': 'EQUITY',
 'currency': 'THB',
 'market': 'th_market',
 'financialCurrency': 'THB',
 'averageDailyVolume3Month': 48305487,
 'averageDailyVolume10Day': 29637716,
 'fiftyTwoWeekLowChange': 3.75,
 'fiftyTwoWeekLowChangePercent': 0.09202454,
 'fiftyTwoWeekRange': '40.75 - 52.25',
 'fiftyTwoWeekHighChange': -7.75,
 'fiftyTwoWeekHighChangePercent': -0.14832535,
 'fiftyTwoWeekLow': 40.75,
 'fiftyTwoWeekHigh': 52.25,
 'earningsTimestamp': 1573480800,
 'earningsTimestampStart': 1550480400,
 'earningsTimestampEnd': 1550826000,
 'trailingAnnualDividendRate': 2.1,
 'trailingPE': 12.228635,
 'trailingAnnualDividendYield': 0.047457624,
 'epsTrailingTwelveMonths': 3.639,
 'epsForward': 4.93,
 'bookValue': 30.561,
 'priceHint': 2,
 'sharesOutstanding': 28562999296,
 'regularMarketChangePercent': 0.56497175,
 'regularMarketDayRange': '44.0 - 44.75',
 'regularMarketPreviousClose': 44.25,
 'bid': 44.25,
 'ask': 44.5,
 'bidSize': 0,
 'askSize': 0,
 'messageBoardId': 'finmb_5469268',
 'fullExchangeName': 'Thailand',
 'longName': 'PTT Public Company Limited',
 'fiftyDayAverage': 45.40625,
 'fiftyDayAverageChange': -0.90625,
 'fiftyDayAverageChangePercent': -0.019958707,
 'twoHundredDayAverage': 46.589287,
 'twoHundredDayAverageChange': -2.0892868,
 'twoHundredDayAverageChangePercent': -0.04484479,
 'marketCap': 1271053418496,
 'forwardPE': 9.026369,
 'priceToBook': 1.4561042,
 'sourceInterval': 15,
 'exchangeTimezoneName': 'Asia/Bangkok',
 'exchangeTimezoneShortName': 'ICT',
 'gmtOffSetMilliseconds': 25200000,
 'esgPopulated': False,
 'tradeable': False,
 'triggerable': False,
 'regularMarketPrice': 44.5,
 'regularMarketTime': 1571391547,
 'regularMarketChange': 0.25,
 'regularMarketOpen': 44.25,
 'regularMarketDayHigh': 44.75,
 'regularMarketDayLow': 44.0,
 'regularMarketVolume': 25782300,
 'marketState': 'CLOSED',
 'shortName': 'PTT PUBLIC COMPANY LIMITED',
 'exchangeDataDelayedBy': 15,
 'exchange': 'SET',
 'symbol': 'PTT.BK'}
```

### Stock US. Large Cap

```python
import pandas as pd
n = ['ticker','last','cht_percent','change','rating','vol','mkt_cap','p_e','eps','a','sector']
data = pd.read_html('https://www.tradingview.com/markets/stocks-usa/market-movers-large-cap/')
df = data[0].copy()
df.columns = n

# นำข้อมูล ticker มา split คำ
df.ticker
a = df.ticker

# split เพียงรายการแรก (ตัวอื่นไม่ต้องทำอะไร)
s = a.str.split(" ",expand=True, n=1)
s
```

| ID | Ticeer | Company |
| -- | ------ | ------- |

| 0 | AAPL | Apple Inc |
| - | ---- | --------- |

| 1 | MSFT | Microsoft Corp. |
| - | ---- | --------------- |

| 2 | AMZN | AMAZON COM INC |
| - | ---- | -------------- |

| 3 | GOOG | Alphabet Inc (Google) Class C |
| - | ---- | ----------------------------- |

| 4 | GOOGL | Alphabet Inc (Google) Class A |
| - | ----- | ----------------------------- |

| ... | ... | ... |
| --- | --- | --- |

| 95 | SPGI | S\&P GLOBAL INC |
| -- | ---- | --------------- |

| 96 | UN | UNILEVER NV EUR0.16(NEW YORK SHARES) |
| -- | -- | ------------------------------------ |

| 97 | ISRG | INTUITIVE SURGICAL INC |
| -- | ---- | ---------------------- |

| 98 | Z | ZM ZOOM VIDEO COMMUNICATIONS INC |
| -- | - | -------------------------------- |

| 99 | MS | MORGAN STANLEY |
| -- | -- | -------------- |

