Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't extract the data out of the tuple while using the get data eikon package with the refinitiv API

# Use the Data Item Browser to find the name of the TR
## Manually calculate the PE

   test = ek.get_data(['IBM','AAPL.O'],['TR.DPSmean','TR.PriceClose'])
   test

OUTPUT

  Out[36]: 
  (  Instrument  Dividend Per Share - Mean  Price Close
 0        IBM                      6.675       140.88
 1     AAPL.O                    0.97507       132.23,
 None)

Here is where I retrieve the infos. What I want to do is just simply divide the Price close by the dividend per share But every time I get a tuple error, whether I just want to print or divide

I tryed every solution that chatgpt proposed me including the pandas package, the index solution and some others but every time it is a tuple problem

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I’m assuming the first element in the tuple is a dataframe, so:

df = test[0]
df["Result"] = df["Price Close"] / df["Dividend Per Share - Mean"]

print(df)

Prints:

  Instrument  Dividend Per Share - Mean  Price Close      Result
0        IBM                    6.67500       140.88   21.105618
1     AAPL.O                    0.97507       132.23  135.610777
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading