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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
32 5 4 2

How do I turn my get_data() output into a dataframe?

How do I turn my get_data() output into a dataframe? I'd like the index to be the RIC and the column headings to be the fields.

I believe the output is currently a tuple.

#import packages 
import eikon as ek # the Eikon Python wrapper package 
import pandas as pd 
import numpy as np 
import datetime from datetime 
import timedelta, date, datetime 
from dateutil.relativedelta import relativedelta 

#connects to Bill's Eikon terminal 
ek.set_app_key('XXXX') 

test_1 = ek.get_data('TSLA.O', 
        ['TR.NumOfStrongBuy',
         'TR.NumOfBuy',
         'TR.NumOfHold',
         'TR.NumOfSell',
         'TR.NumOfStrongSell'])

print(test_1)
Thanks
eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonapi
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.

1 Answer

Upvotes
Accepted
9.5k 10 5 7

Hello @bill39

Normally, get_data(..) returns pandas.DataFrame and errors as explained in Eikon Data APIs for Python - Reference Guide.

The example source code below shows how to get DataFrame and the index to be the RIC and the column headings to be the fields.

#return dataframe and errors
test_1,err= ek.get_data('TSLA.O', 
        ['TR.NumOfStrongBuy',
         'TR.NumOfBuy',
         'TR.NumOfHold',
         'TR.NumOfSell',
         'TR.NumOfStrongSell'])
print(type(test_1))
#set index to be RIC
test_1.set_index('Instrument', inplace=True) 
#show data
test_1

The example output:


output.png (8.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.

Click below to post an Idea Post Idea