Eikon Python API

https://pypi.org/project/eikon/

Version 1.0.1.

When ask CUSIP, API returns formatted data.

For example

IMAX,4.5245e+113 (WRONG, should be 45245E109)

NNFC,6.3008e+113 (WRONG, should be 63008E109)

AAPL,37833100 (WRONG, should be 0 in the begin)

Problem in method get_data_frame(data_dict, field_name=False)

246 string should be deleted:

#df = df.apply(pd.to_numeric, errors='ignore')

Then result is OK. Please fix it.

Best Answer

  • @vsoloviev et all,
    The data is retrieved from a RESTful Web service and is delivered as JSON. get_data function parses JSON and constructs pandas dataframe. To make numeric data ready available for calculations get_data function applies pandas to_numeric method on the dataframe. The side effect of it is that any data pandas to_numeric method can interpret as numeric is returned as float64 or int64 including what is actually intended to be a string such as CUSIPs in the example on this thread. We could remove to_numeric method from get_data function. But then users may need to implement additional code before applying calculations on the data that is meant to be numeric.
    We welcome suggestions from the community on how to best handle this in the API. Do you think calling pandas to_numeric method is unnecessary or redundant? Or can you think of a better way to make the dataframe returned by get_data method ready to use?
    In the meantime as an immediate workaround you can use raw_output=True parameter in get_data function, which will result in the function returning JSON instead of dataframe. You can then parse JSON as you see fit. Alternatively you could modify the code in get_data_frame function in your copy of data_grid.py (e.g. remove the line that applies to_numeric method on the dataframe).

Answers