Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Eikon Data APIs /
avatar image
Question by DNKala · Apr 04, 2019 at 09:27 PM · pythoneikon apipython api eikonrefinitivthomson eikon

Trying to convert Total Return in a dataframe from Object type to float64 type. Not working.

I have a dataframe TSRdfr which I have accessed from Eikon API on Python.

Index Instrument Total Return

1. RIO.L. 15.990065

2. AAP.A. 22.543209

and so on ....

The data type of Total Return is Object which I need to convert to float64. I am using the syntax below.

TSRdfr["Total Return"] = pd.to_numeric(TSRdfr["Total Return"], errors='coerce')

This is not converting the data type of Return from Object to float64. I tried removing errors ='coerce' to see what's happening.

I am getting an error saying: "Unable to parse NaN at position 0"

The Return numbers are accessed from Refinitiv Eikon API. I am assuming they are too large to convert to float64. Any suggestions??

I know this question is not specific to Eikon API, but some help will be appreciated.

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Reply

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by Alex Putkov. · Apr 05, 2019 at 05:03 PM

It's hard to say what's going on without having a copy of the dataframe or knowing exactly how it was created. Your assumption that the total return number is too large is definitely incorrect. Numeric data is returned by Eikon Data APIs as float64. Here's an example.

>>> df, err = ek.get_data(["RIO.L","AAP.A"],["TR.TotalReturn"])
>>> type(df['Total Return'][0])
<class 'numpy.float64'>
More specifically, when get_data method constructs the dataframe and populates it with the values extracted from JSON retrieved from the Web service delivering the data, the method applies pandas to_numeric function to each column of the dataframe before returning the result. If your dataframe is constructed using get_data method there's no point in applying to_numeric function again.
What struck me in your depiction of your dataframe is that the index appears to start at 1 and not at 0. I cannot help but wonder how this happened and whether this is related to to_numeric method applied to 'Total Return' column returning "Unable to parse NaN at position 0".
Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
10 People are following this question.

Related Questions

First search result return for a RIC

Request Intraday Forex Data using Python API.

Issue while requesting Stock Returns (TR.TotalReturn1D)

In eikon Python api function eikon.get_news_headlines() are results inclusive of date_from and date_to timestamps parameters?

additional charges for Registering a New App in the App Key Generator

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges