question

Upvotes
Accepted
1 0 0 0

How can I get the following API data pulls to come out in dataframe format?

Here is the block of code I'm using, where "sublist" is a group of 100 ISINs

timer = Event()


while True:

try:

Output_df = []

for sublist in chunklist:

data7, err =ek.get_data(sublist, fields=["TR.EmissionReductionTargetPctage","TR.EmissionReductionTargetYear","TR.GenderPayGapPctage","TR.HSMSCertifiedPercent","TR.AnalyticBoardMemberComp","TR.AnalyticBoardAffiliations","TR.VoluntaryTurnoverEmployees","TR.StockBasedCompActual"],parameters=None, field_name=False, raw_output=False, debug=False)

Output_df.append(data7)


Output_df = pd.concat(Output_df)

break

except ek.EikonError as err:

if err.code != 2504:


break


timer.wait(1)



I have run a similar loop in the past that creates a dataframe and appends all of the data, but for this one my output is coming out in lists which I cannot export

#technologypython 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.

1 Answer

· Write an Answer
Upvotes
Accepted
19k 85 39 63

Hi @cole,

Try the following:

Output_df = pd.DataFrame()

Then in the loop, you can build up the final dataframe with this code:

Output_df = Output_df.append(data7, ignore_index=True)
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.