Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Datastream /
avatar image
Question by charles.malafosse · Mar 25, 2019 at 12:44 PM · apipythondatastreamdataframe

Cannot make sense of dataframe format returned by Python datastream API PyDSWS

Hello,

I use the simple python line of code to get the constituents of S&P500:

data1= ds.get_data(tickers="LS&PCOMP", fields='P,PE,MV,NAME,RIC')

However I cannot make sense of the dataframe it returns. It seems to have multiple layers and I can't see how to iterate through the dataframe to create a simple list of (Id, P,PE,MV,NAME,RIC) for each constituent of S&P500.

data1
Out[114]: 
Instrument   891399 916328 545101  777953  906187 936365    749382  891631  \
Field             P      P      P       P       P      P         P       P   
Date                                                                         
2019-03-22  1764.77  77.97  18.06  323.21  139.45  26.37  259.6899  141.72   

I am sure it's not that difficult but I would greatly appreciate help on this.

Many thanks.

Charles

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
Best Answer
Answer by charles.malafosse · Mar 26, 2019 at 11:47 AM

I found a solution.

The dataframe returned has a multi index. I wish the documentation on the community dev website would clearly mention that.

Here is what I use to get the data for each constituent:

	df_index = data1.transpose()
        for item in df_index.index.get_level_values(0):
            print(item)
            print(df_index.xs(item))

Comment
Teodora Nicole.Stelea_deprecated_0
thomas.schmelzer

People who like this

2 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 >
7 People are following this question.

Related Questions

I can access DSWS via Excel but not via DatastreamDSWS2R

How will I be able to solve this?

DSWS API - What is the pricing for this method of accessing the data?

Datastream Data availaible via Excel Request-Table - But not via R-API

Datastream Python API - ConnectionError

  • 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