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

Best Answer

  • 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)