Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

Python - Quandl

$
0
0

Comments:" Python - Quandl "

URL:http://www.quandl.com/help/python


The Quandl API is now available via a python package, and can be found on PyPi and at our Python GitHub page. Download from PyPi and install as with any Python package. From Github, download the Quandl folder and place it in your python library folder, or edit your PYTHONPATH file.

Required libraries:

Example

An example of creating a pandas data series for IBM stock data, with a weekly frequency

import Quandl
data = Quandl.get("GOOG/NYSE_IBM",frequency="weekly")
data.head()

will output:

No authentication tokens found,usage will be limited 
Returning Dataframe for GOOG/NYSE_IBM
 Open High Low Close Volume
Date 
2013-03-28 209.83 213.44 209.74 213.30 3752999
2013-03-15 215.38 215.90 213.41 214.92 7937244
2013-03-08 209.85 210.74 209.43 210.38 3700986
2013-03-01 200.65 202.94 199.36 202.91 3309434
2013-02-22 199.23 201.09 198.84 201.09 3107976

Package Features

For prolonged use, more than 10 calls a day, you will need to register an account with Quandl to get an authentication token. Go to your account page, after creating an account, and click on the API tab. This token will allow you to make 100 calls per day. If you wish more API calls please contact us, and we will be more than happy to help you.

When calling the function simply paste your authtoken, only necessary on first use, and then it will be stored on your computer for continued use.

Quandl.get("NSE/OIL", authtoken="your token here").

API capabilities

Our Python package has all of the basic Quandl API capabilities built in. Allowing you to:

  • Truncate dates Quandl.get("NSE/OIL",startdate ="March 2005", enddate="December 2010")

  • Change data frequency Quandl.get("NSE/OIL",frequency="monthly") (daily|weekly|monthly|quarterly|annual)

  • Perform a transformation on the data Quandl.get("NSE/OIL", transformation = "cummul") (diff|rdiff|cummul|normalize)

  • Return only n rows Quandl.get("NSE/OIL", rows = 5)

Uploads

You can now upload your own data to Quandl through the Python package.

At this time the only accepted format is a date indexed Pandas DataSeries.

Things to do before you upload:

  • Make an account and set your authentication token within the package with the Quandl.auth() function.
  • Get your data into a data frame with the dates in the first column.
  • Pick a code for your dataset - only capital letters, numbers and underscores are acceptable.

Then call this functionQuandl.push(data,code = "TEST", name ="Test", desc="test") All parameters but desc are necessary

if you wish to override the existing set at code TEST add override= True

Example

Uploading a pandas DataSeries with random data

data = pandas.DataFrame(numpy.random.randn(6, 3), index=['Dec 12 2296', 'Dec 21 1998', 'Oct 9 2000','Oct 19 2001', 'Oct 30 2003', 'Nov 12 2003'],columns=['D', 'B', 'C'])
print Quandl.push(data,code = "F32C", name ="Test", desc="test", authtoken = "YOURTOKENHERE")

Will return the link to your newly uploaded data

Available Data Types

The Quandl package is able to return data in 2 formats, a pandas data series ("pandas") or a numpy array("numpy"). Defaults to "pandas"

`Quandl.get("NSE/OIL",returns="numpy")`

Feedback

We welcome comments, suggestions and bug reports. Pull requests are even better!

License

MIT License.

Credits

Mark Hartney programmed the first version of this package.


Viewing all articles
Browse latest Browse all 9433

Trending Articles