quandl / quandl-python

MIT License
1.38k stars 338 forks source link

Subsetting by columns fails with one share #17

Closed hexagon5un closed 8 years ago

hexagon5un commented 10 years ago

Don't know if this is expected behavior or not (it wasn't to me).

In short,if you want to get one share:

foo = Quandl.get('GOOG/NYSE_AAPL') 

works, but if you want to get one column from one share

foo = Quandl.get('GOOG/NYSE_AAPL.4')

doesn't.

You can get single columns from multiple shares (as on the python demo page):

 foo = Quandl.get(['GOOG/NYSE_AAPL.4','GOOG/NASDAQ_MSFT.4']) 

And you can also get a column from one share by making it a one-item list:

foo = Quandl.get(['GOOG/NYSE_AAPL.4'])

so it's not a show-stopper, but rather a failure of expectations about the way the "retrieve just one column" thing works.


And while I'm on the subject, Python uses 0-indexed arrays. The fourth column of a Python array bar is

bar[3]

which causes a tiny bit of mental dissonance when I have to type ".4" to fetch the fourth column from the Quandl server in Python.

ChrisStevens commented 10 years ago

That is expected behaviour, ie. it is in line with Quandl's API behaviour.

The column indexing is sort of interesting, It would be kind of odd coming from Quandl/using the API where numbering starts at 1, but I can understand the idea behind it. Does anyone have thoughts on this one? I am rather hesitant to change something like that however, since it has the possibility of seriously breaking peoples code if they update not knowing of the change.

hexagon5un commented 10 years ago

I just started working with the Python libs, and was just documenting where I ran into friction along the way while trying to use the API. (Hope it helps.) I can imagine that changing to zero-indexing now would break a lot of existing code, so I'm sure you don't want to do it, and C/Python people are pretty much used to worrying about the issue anyway.

Maybe a sentence on the website/docs to alert folks to the one-offset in the API?

The first issue still strikes me as odd, and I bet it can be patched in a couple lines of code. I'll get on that and see, if just for my own satisfaction.

hexagon5un commented 10 years ago

Nevermind. I see it's a "datasets" vs "multisets" issue for the backend API. Working around will just be ugly. Please ignore me. :)