question

Upvotes
Accepted
32 8 6 7

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-apipythonworkspacerefinitiv-dataplatform-eikonworkspace-data-apiapi
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.

1 Answer

· Write an Answer
Upvotes
Accepted
9.6k 10 7 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 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.