[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.

Best Answer

  • jorge.santos
    Answer ✓

    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.

Answers

  • 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)