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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 1 0 2

how to retrieve the specific field from data?

eur=ek.get_data("EUR=FXAL", {'CF_BID':{}}, {'CF_ASK':{}}, {'CF_LAST':{}}, {'CF_CLOSE':{}}, print(eur)

Result:

( Instrument CF_BID CF_ASK CF_LAST CF_CLOSE0 EUR=FXAL 1.1704 1.17052 1.1704 1.17187, None)

For example,if i only want to retrieve 1.1704 from result ,how can i do?Thank you.

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
icon clock
10 |1500

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

Upvotes
Accepted
9.7k 49 38 60

Hi @penny.poon,

You can try this:


ahs.png (7.9 KiB)
icon clock
10 |1500

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

Upvote
4.3k 2 4 5

You should retrieve separately result and error from get_data :
>>> eur, error = ek.get_data("EUR=FXAL", ["CF_BID", "CF_ASK", "CF_LAST", "CF_CLOSE"])

>>> eur
Instrument CF_BID CF_ASK CF_LAST CF_CLOSE

0 EUR=FXAL 1.17042 1.17056 1.17042 1.17187

Then, you can retrieve the CF_BID value :
>>> eur.iloc[0][1] (or eur["CF_BID"][0] )

1.17042

For CF_CLOSE, just modify the index :

>>> eur.iloc[0][4] (or eur["CF_CLOSE"][0] )

1.17187

edit: a like for Nick's answer that give a field name access !

icon clock
10 |1500

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

Click below to post an Idea Post Idea