question

Upvote
Accepted
22 5 3 7

Get an clean data from Api in python

Hi, I'm introducing the following code to get the data via api. There are many row that are empty. There will be some code that I can put so that the empty data is put by N.A and separated by ","

ek.get_timeseries(['AGR.BA','ALU.BA','APBR.BA','AUS.BA','HI.BA','MA.BA','BPAT.BA','BYMA.BA', 'CAMb.BA','CAO.BA','CARC.BA','CAU.BA','CEC.BA','CEL.BA','CEPU.BA','CLA.BA', 'COL.BA','COM.BA','CON.BA','CPS.BA','CRE.BA','CVH.BA','DOM.BA','DYC.BA', 'ECO.BA','EDLH.BA','EDN.BA','EDSH.BA','EMD.BA','ESM.BA','FER.BA','FIP.BA', 'FRA.BA','GAR.BA','GBA.BA','GFG.BA','GRM.BA','HARG.BA','HAVH.BA','INA.BA', 'INR.BA','INU.BA','INVJ.BA','IRCP.BA','IRS.BA','LED.BA','LOMA.BA','LON.BA', 'MERA.BA','MET.BA','MIR.BA','MOL.BA','MOLA.BA','MOR.BA','OEST.BA','PAM.BA', 'PAT.BA','PETR.BA','PGR.BA','POL.BA','PSU.BA','QUI.BA','REP.BA','RICH.BA', 'RIG.BA','RIO.BA','ROS.BA','SEI.BA','SMI.BA','STD.BA','SUPV.BA','TEC2.BA', 'TEF.BA','TENA.BA','TGLT.BA','TGNC.BA','TGS2.BA','TRA.BA','TXAR.BA','VAL.BA', 'YPFD.BA','YPFD.BA'], start_date='2000-01-01' , end_date='2018-01-01')

df.to_csv('galicia_2016_20128.csv')

eikoneikon-data-apipythonworkspacerefinitiv-dataplatform-eikonworkspace-data-apiapidata
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
19.1k 86 39 63

Hi @pablo,

If I understand you correctly, you would like to replace the empty data that appears in you file with some value like "NA"? If so, try this:

df = df.fillna('NA')
df.to_csv('galicia_2016_20128.csv')
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.