Closed jlowin closed 11 years ago
Quandl's API gives the choice of whether you'd like to have the data returned ascending or descending so there's no need to flip the array around within python. You can just append this to the url string.
sort_order=asc|desc
Example:
http://www.quandl.com/api/v1/datasets/DOE/RWTC.csv?collapse=quarterly&sort_order=asc
@RaymondMcT Great! That makes this even cleaner.
Quandl.com uses a descending convention for sorting dates (newest information at the top). However, Pandas uses an ascending convention. Therefore, with data imported via the current function, Pandas timeseries methods like
data.diff()
,data.pct_change()
, ordata.shift()
give unexpected results (looking forward in time, rather than back) and advanced timeseries indexing likedata.ix['Nov 2010' : 'May 2011']
fails with an error.This PR sorts imported data in ascending order by default in order to keep compatibility with Pandas, but lets users revert to descending order by passing
ascending=False
. This way equivalency can be maintained with manually downloaded datasets (that are in descending order).Please note that this is a very small PR -- only 5 lines of functionality in the first commit. The second commit makes a number of minor PEP8/formatting fixes that clean up the code but add no functionality. However, it touches many lines, possibly making this appear like a much larger PR than it actually is.