Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
5 5 5 8

[eikon.get_data] Inconsistent output data conventions?

What's the rational for throwing this error?

data, err = eikon.get_data('SPY', fields='TR.FundBenchmarkName', raw_output=True)
[Error: too many values to unpack]

Wouldn't be more consistent to retrieve a datatype independent of the number of values to unpack? In addition, when raw_output=False I think that we are supposed to retrieve a pandas.DataFrame and not a tuple according to the documentation.

data = eikon.get_data('SPY', fields='TR.FundBenchmarkName', raw_output=False)
type(data): tuple

data, err = eikon.get_data('SPY', fields='TR.FundBenchmarkName', raw_output=False)
type(data): pandas.DataFrame

data = eikon.get_data('SPY', fields='TR.FundBenchmarkName', raw_output=True) type(data) is dict.
eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
434 1 2 2

Hi @federico.fontana you are right. The documentation is misleading. We will fix this.

get_data will always return a tuple

result = eikon.get_data()
result[0] = pd.DataFrame with the results
result[1] = errors

The get_data set of results can be very large of for a large universe. You wouldnt want to fail the entire request if one of the values is missing, therefore data errors (missing values, invalid fields, wrong parameters) etc are part of the errors response.

you can always unpack them directly:

results , err=eikon.get_data()

Or if you dont care about errors

results = eikon.get_data()[0]

And yes `raw_output=True` will always be a dictionary for all types of requests.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvote
4.6k 26 7 22

@federico.fontana

According to the package description:

Returns
-------
pandas.DataFrame
        Returns pandas.DataFrame with fields in columns and instruments as row index
errors
        Returns a list of errors

So it is indeed a tuple of two objects: a data frame and a list of errors (which is of NoneType if the request is successful)

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.