How do I aggregate with the Python API?

I can aggregate country market capitalization in Excel with:


=TRAggregate("SCREEN(U(IN(EQUITY(Public,Active,Primary))),TR.CompanyMarketCap(CURN=USD)>=50000000)","TR.CompanyMarketCap(Curn=USD)","TR.HQCountryCode")


How do I get this through the Eikon Python API? Here's my best guess, but it is not working:

df, err = ek.get_data("TRAggregate(SCREEN(U(IN(EQUITY(Public,Active,Primary))),TR.CompanyMarketCap(CURN=USD)>=50000000),TR.CompanyMarketCap(Curn=USD),TR.HQCountryCode)","na")


I could retrieve all the data, and aggregate in Python using "df, err = ek.get_data("SCREEN(U(IN(Equity( ..." , but that would be inefficient. Right?


Thanks,

Brent

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @Brent Gregory

    TRAggregate is an excel function so it could not be used in the ek.get_data method.

    Yes, you are correct. You need to retrieve all the data and aggregate it in Python.