From f138bba26cd24e0275e307f87e9d8dbb324942f3 Mon Sep 17 00:00:00 2001 From: Isaac Hodes Date: Thu, 25 Apr 2013 18:32:21 -0400 Subject: [PATCH] Set default sort_order to asc --- Quandl/Quandl.py | 13 +++++++------ README.md | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Quandl/Quandl.py b/Quandl/Quandl.py index 020f9da..37d58ff 100644 --- a/Quandl/Quandl.py +++ b/Quandl/Quandl.py @@ -33,28 +33,29 @@ def get(dataset, **kwargs): :param str authtoken: Downloads are limited to 10 unless token is specified :param str trim_start, trim_end: Optional datefilers, otherwise entire dataset is returned - :param str frequency: Options are daily, weekly, monthly, quarterly, annual + :param str collapse: Options are daily, weekly, monthly, quarterly, annual :param str transformation: options are diff, rdiff, cumul, and normalize :param int rows: Number of rows which will be returned - :param str sort_order: options are asc, desc. Default: `desc` - :param str returns: specify what format you wish your dataset returned as, + :param str sort_order: options are asc, desc. Default: `asc` + :param str returns: specify what format you wish your dataset returned as, either `numpy` for a numpy ndarray or `pandas`. Default: `pandas` :returns: :class:`pandas.DataFrame` or :class:`numpy.ndarray` Note that Pandas expects timeseries data to be sorted ascending for most - timeseries functionality to work. + timeseries functionality to work. Any other `kwargs` passed to `get` are sent as field/value params to Quandl with no interference. """ + kwargs.setdefault('sort_order', 'asc') + auth_token = _getauthtoken(kwargs.pop('authtoken', '')) trim_start = _parse_dates(kwargs.pop('trim_start', None)) trim_end = _parse_dates(kwargs.pop('trim_end', None)) - returns = kwargs.pop('returns', 'pandas') + returns = kwargs.get('returns', 'pandas') url = QUANDL_API_URL + 'datasets/{}.csv?'.format(dataset) - url = _append_query_fields(url, auth_token=auth_token, trim_start=trim_start, diff --git a/README.md b/README.md index e970206..60c8f5a 100644 --- a/README.md +++ b/README.md @@ -10,18 +10,18 @@ An example of creating a pandas time series for IBM stock data, with a weekly fr ```python import Quandl -data = Quandl.get("GOOG/NYSE_IBM", frequency="weekly") +data = Quandl.get('GOOG/NYSE_IBM', collapse='weekly') data.head() ``` will output ``` -No authentication tokens found,usage will be limited +No authentication tokens found,usage will be limited Returning Dataframe for GOOG/NYSE_IBM Open High Low Close Volume -Date +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 @@ -38,7 +38,7 @@ A request with a full list of options would be the following. ```python import Quandl data = Quandl.get('PRAGUESE/PX', authtoken='xxxxxx', trim_start='2001-01-01', - trim_end='2010-01-01', frequency='annual', + trim_end='2010-01-01', collapse='annual', transformation='rdiff', rows=4, returns='numpy') ``` @@ -58,7 +58,7 @@ Quarterly normalized crude oil prices since 2005, only returning first 4 values. ```python import Quandl -data = Quandl.get('IMF/POILAPSP_INDEX', frequency='quarterly', +data = Quandl.get('IMF/POILAPSP_INDEX', collapse='quarterly', trim_start='2005', transformation='normalize', rows='4') data.head() ````