- Hands-On Data Science with Anaconda
- Dr. Yuxing Yan James Yan
- 354字
- 2021-06-25 21:08:49
Introduction to the Quandl data delivery platform
Quandl is a data delivery platform that includes many free datasets. Its website is https://www.quandl.com. The following are a few programs written in R or Python to download data from the platform. The following program retrieves the latest 50 trading days' data for International Business Machine (IBM):
> library(Quandl) > x<- Quandl.dataset.get("WIKI/ibm", list(rows=50)) > head(x,2) Date Open High Low Close Volume Ex-Dividend 1 2018-01-09 163.90 164.530 163.060 163.83 4333418 0 2 2018-01-08 162.66 163.905 161.701 163.47 5101023 0 Split Ratio Adj. Open Adj. High Adj. Low Adj. Close Adj. Volume 1 1 163.90 164.530 163.060 163.83 4333418 2 1 162.66 163.905 161.701 163.47 5101023
Note that we just need to issue the first two lines in the code once. The following code would get the data for a Chinese company with a ticker symbol of 601628. Obviously, DY4 is for Chinese data:
import Quandl as qd y<- Quandl.dataset.get("DY4/601628", list(rows=50)) > head(y,2)
The corresponding output is shown here:

For the following R program, we assume that the Quandl application key is contained in the myQuandlKey variable. Later in the chapter, we explain how to get a Quandl application key:
> library(Quandl) > Quandl.api_key(myQuandlKey) > x<- Quandl.dataset.get("WIKI/wmt", list(rows=500))
For Python, we have the following code to download the Gross Domestic Product (GDP) from Quandl:
import quandl x= quandl.get("FRED/GDP") x.head() Value Date 1947-01-01 243.080 1947-04-01 246.267 1947-07-01 250.115 1947-10-01 260.309 1948-01-01 266.173
The format of the output dataset is a pandas data frame. Quandl can also return data as a numpy array, shown here:
import quandl x=quandl.get("FRED/GDP",returns="pandas") y=quandl.get("FRED/GDP",returns="numpy")
The following table shows patterns for different sources of data from the Quandl data platform:

Table 3.6: Max number of calls every 10 min and every day for Quandl users
The next program shows how to retrieve Walmart data for free subscribers, as in, those with a Quandl application key. Being a free subscriber means that you register with Quandl without paying any fees:
import quandl as qd quandl.ApiConfig.api_key = 'YOUR_API_KEY' y=qd.get("WIKI/WMT") y.head(2) y.tail(1)
The output is shown here:

The second line of quandl.ApiConfig.api_key = 'YOUR_API_KEY' indicates that a user has to enter his/her Quandl application key.
- 輕松學C語言
- Visualforce Development Cookbook(Second Edition)
- 計算機控制技術
- Visual Basic從初學到精通
- 計算機網絡技術基礎
- 21天學通Java Web開發
- Hands-On Reactive Programming with Reactor
- Cloud Security Automation
- Salesforce Advanced Administrator Certification Guide
- 網絡脆弱性掃描產品原理及應用
- 筆記本電腦電路分析與故障診斷
- Learn Microsoft Azure
- 案例解說Delphi典型控制應用
- Hands-On Business Intelligence with Qlik Sense
- PHP求職寶典