Skip to content

Commit

Permalink
Set default sort_order to asc
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Hodes committed Apr 25, 2013
1 parent 2da1c01 commit f138bba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
13 changes: 7 additions & 6 deletions Quandl/Quandl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
```

Expand All @@ -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()
````
Expand Down

0 comments on commit f138bba

Please sign in to comment.