Sdate & Edate python api

Hi, Below is my code :

etf_esg, err = ek.get-data('0#.'XUTUM', ['TR.TRESGScore','TR.TRESGCScore','TR.EnvironmentPillarScore'])

I know as some companies in XUTUM having already published their score 2022, others haven't yet, some securities have the data begin in 2022 / others in 2021.

I need a python code for me to get both 2021 and 2022 scores in "excel output" so that they will be show in two seperate columns.

Regards,

Best Answer

  • frank.ling1
    Answer ✓

    Hi gaye.sakarya,


    You may try following codes:

    etf_esg, err = ek.get_data('0#.XUTUM', ['TR.TRESGScore.date','TR.TRESGScore','TR.TRESGCScore','TR.EnvironmentPillarScore'],

    {'SDate':'0', 'EDate':'-2','Period':'FY0','Frq':'FY'})

    etf_esg['Date']=etf_esg['Date'].astype('str')

    etf_esg['Date']=etf_esg['Date'].apply(lambda x: x[:10])

    etf_esg = etf_esg[etf_esg['Date']>='2021']

    etf_esg


    api.png

Answers