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
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-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
17.2k 82 39 63

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 512.0 KiB each and 1.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 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.