quandl / quandl-python

MIT License
1.37k stars 336 forks source link

Documentation is absolutely garbage #85

Closed priestc closed 7 years ago

priestc commented 7 years ago

Sorry, but I have to be frank. I'm sure the code is very good, but the documentation doesn't tell how to use the library. I want the data to get the exchange rate between BTC and LTC. I found this page on the Qualdt site:

https://www.quandl.com/data/BTCE/BTCLTC-BTC-LTC-Exchange-Rate

It tells me to use the code here:

quandl.get("BTCE/BTCLTC", authtoken="my_code")

When install the quandl python library and then paste that code into the shell, I get this:

In [57]: quandl.get("BTCE/BTCLTC", authtoken="my_code")
Out[57]:
High       Low   Average     Last      Buy     Sell  \
Date
2012-07-15  0.005990  0.005264       NaN      NaN      NaN      NaN
2012-07-16  0.006990  0.005519       NaN      NaN      NaN      NaN
2012-07-17  0.007000  0.005091       NaN      NaN      NaN      NaN
2012-07-18  0.006760  0.005000       NaN      NaN      NaN      NaN
2012-07-19  0.005899  0.005000       NaN      NaN      NaN      NaN
2012-07-20  0.007000  0.004900       NaN      NaN      NaN      NaN
2012-07-21  0.006200  0.005550       NaN      NaN      NaN      NaN
2012-07-22  0.006300  0.005556       NaN      NaN      NaN      NaN
2012-07-23  0.006499  0.005601       NaN      NaN      NaN      NaN
2012-07-24  0.006200  0.005244       NaN      NaN      NaN      NaN
2012-07-25  0.005999  0.003503       NaN      NaN      NaN      NaN
2012-07-26  0.005925  0.005050       NaN      NaN      NaN      NaN

The object that is returned seems to be a pandas DataFrame object. How can I iterate through the data found in this dataframe object? The documentation tells me a billion things about everything I don't want to know, but doesn't tell me what I need to know. All I need from the dataset is the average price, and the date.

I tried

[x for x in quandl.get("BTCE/BTCLTC", authtoken="my_code")]

But that doesn't work

I also tried to get the first line in the dataset:

quandl.get("BTCE/BTCLTC", authtoken="my_code")[0]

But that gives me a key error. I then tried this:

quandl.get("BTCE/BTCLTC", authtoken="my_code").as_list()

but that gives me an attribute error

I did try to do

quandl.get("BTCE/BTCLTC", authtoken="my_code").as_matrix()

which does seem to return data, but there is no "Date" field, which makes the data useless for my use.

Why does this have to be so hard? Its very easy to download a csv file, iterate through it, but this quandl library makes it so much harder.

My suggestion is to modify the documentation near the top to explain how to use the most basic usage of this library, and that is downloading a single dataset (or datatable, or database or whatever you call it) and iterate over the data.

RaymondMcT commented 7 years ago

Once the Quandl data is returned in a pandas dataframe you have to look at pandas documentation to learn how to iterate through it. Quandl’s docs do not include usage of external packages.

This stack overflow topic should be helpful: http://stackoverflow.com/questions/16476924/how-to-iterate-over-rows-in-a-dataframe-in-pandas

You can also check out this primer: http://pandas.pydata.org/pandas-docs/stable/dsintro.html