Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
7 2 2 3

Unable to calculate CAGR for total return extracted from Eikon API

I have a dataframe with Total Return for a few RICs

TSRdf_1_2002, e = ek.get_data(TSR_ric_list_1, ['TR.TotalReturn'],{'SDate':'2002-06-30', 'EDate':'2005-06-30'})

I am trying to calculate CAGr for this as follows:

TSRdf_1_2002['TSR_02_05'] = ((TSRdf_1_2002['Total Return']+100)/100)**(1/3)-1

Getting the following error:

TypeError: must be str, not int

I have tried these as well:
When trying to convert the dataframe column to numeric, I get

TSRdf_1_2002['TSR_02_05'] = pd.to_numeric(TSRdf_1_2002['Total Return'])

ValueError: Unable to parse string "NaN" at position 853

Tried to replace the NaNs, the line gets executed but continue to get the parse string error above

TSRdf_1_2002 = TSRdf_1_2002.replace(np.nan, '')

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apidata
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.

@DNKala
Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query? If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.
Thanks,
-AHS

1 Answer

· Write an Answer
Upvotes
Accepted
4.6k 26 7 22

@deepika.naga.k this is not an Eikon issue, but a general pandas question. If you still would like some assistance, I will need the contents TSR_ric_list_1.

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.