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

Question:

# 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

Asked By: Hugo MISZCZAK

||

Answers:

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
Answered By: Andrej Kesely
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.