Datastream Point in Time Data Manipulation

Hi as the Point in Time data returns a multi-index dataframe, i am having trouble accessing the Dates Column. i intend to set the dates column as an index and to concat on the basis of the dates with another dataframe. Can you let me know how i should go about doing this

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @ken03

    Thank you for sharing the code.

    I ran the code and found that Dates is already an index.1682069016795.png

    You may refer to this article on Medium regarding How to flatten MultiIndex Columns and Rows in Pandas.

    I can run the following code to concatenate two data frames by Dates.

    df1 = ds.get_data(tickers='@AAPL, @FB, @GOOGL, @MSFT, @NXPI';, 
                fields=['SOCOO01V','ENPIDP048','SOHRDP012','SOEQ','SOTDDP018','SODODP0012','ENRRDP033','ENERDP052','CGVSDP030'],
                start='-5Y', freq='Y')
    df2 = ds.get_data(tickers='U:JPM, U:XOM, U:BAC, U:BABA, U:V', 
                fields=['SOCOO01V','ENPIDP048','SOHRDP012','SOEQ','SOTDDP018','SODODP0012','ENRRDP033','ENERDP052','CGVSDP030'],
                start='-5Y', freq='Y')
    pd.concat([df1, df2], axis=1)

    The output is:

    1682069285912.png



Answers