Manipulating get_data returns for fiancial data Series (TR.F...)

Trying to get historic financial data for many asset, one field.

Example:

dfEikonTHIS, err = ek.get_data('NESN.S,CSGN.S','TR.F.CF(SDate=0,EDate=-10,Period=FY0,Frq=FY)', parameters=None, field_name=False)

How can I get it to return ASSET as row and each element of FIELD as as columns ... without parsing through the data returned and reformat?

not this


InstrumentCash Flow0NESN.S235580000001NESN.S158370000002NESN.S166170000003NESN.S143920000004NESN.S10653000000


But this


01234NESN.S

2355800000015837000000166170000001439200000010653000000



Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @the.swiss

    The get_data method returns data in the following format.

    dfEikonTHIS, err = ek.get_data('NESN.S,CSGN.S',['TR.F.CF(SDate=0,EDate=-10,Period=FY0,Frq=FY).Date',
                                                   'TR.F.CF(SDate=0,EDate=-10,Period=FY0,Frq=FY)'], parameters=None, field_name=False)
    dfEikonTHIS

    1650856380017.png

    This can't be changed. However, you can use the pivot method to change the format, as shown below.

    dfEikonTHIS.pivot(index='Instrument', columns='Date', values='Cash Flow') 

    The output looks like this.

    1650856435962.png


Answers

  • Many thanks - belatedly - had to go a different route (from pivot ... the term gives me a jolt being an old Excel finance junkie .. ;-) )

    I am using dates 'normalized' as in T-x x being years so those columns would read 0,1,2, ...

    Alfred