I am trying to do the following with some sample code from the library:
- Customize the column headers (at the moment it shows ROUND(TR.EPSMean(Period=FQ1),2), and so on. I searched on Google and believe we use df.rename() but I was unable to incorporate this into the code below.
- Display the entire table of 504 rows instead of the current display of 10.
- Format revenue column to a) display in thousands, and b) zero decimals (i.e. 21446.61589 = 21,446). When I try wrapping ‘round’ around TR.RevenueMean does not work.
- How can I export the contents of my dataframe into an Excel spreadsheet?
It would be great if the below code can be amended with the correct syntax so I can copy it into Codebook and learn how to do this.
Thank you in advance.
import refinitiv.dataplatform.eikon as ek ek.set_app_key('DEFAULT_CODE_BOOK_APP_KEY') df, err = ek.get_data( instruments = ['0#.SPX'], fields = [ 'TR.CommonName', 'TR.GICSSector', 'round(TR.EPSMean(Period=FQ1),2)', 'round(TR.EPSMean(Period=FQ2),2)', 'round(TR.EPSMean(Period=FQ3),2)', 'round(TR.EPSMean(Period=FQ4),2)', 'TR.RevenueMean(Period=FQ1)', 'TR.RevenueMean(Period=FQ2)', 'TR.RevenueMean(Period=FQ3)', 'TR.RevenueMean(Period=FQ4)', ], parameters = { 'Scale': '6', 'Curn': 'USD' } ) display(df)