How do I save down a dataframe from the LSEG Codebook environment to my local drive?

Answers

  • Hello @swasti

    You can either save the dataframe as a pickle, or export it as a CSV file. These files will get saved to your codebook folder in cloud. Then from the left folder navigation bar, you can download the said file to your local drive.

    image.png
  • Hello @swasti

    You can use pandas.DataFrame.to_csv method to save your dataframe to a csv file.

    import lseg.data as ld
    import pandas as pd

    ld.open_session()

    df = ld.get_data(
    universe=['LSEG.L', 'VOD.L'],
    fields=['BID', 'ASK']
    )

    df.to_csv('./dataframe.csv')

    Then right-click on the saved csv file and choose download option.

    df.png

    To upload this csv file (or other files) to CodeBook cloud environment, you can click the upload button (the arrow up icon) as follows.

    df2.png

    Then you can use pandas.read_csv method to convert the CSV file back to dataframe object.

  • swasti
    swasti Newcomer

    No, I am aware you can download via the portal, but it max's out at 10,000. I am pro grammatically trying to export the df via the codebook environment. I tried to_csv but no joy

  • swasti
    swasti Newcomer

    Is there no way I can bypass the physical download to save from LSEG Code book enviroment to my local files?

  • @swasti

    You always have an option to run your notebooks outside of codebook, on your local machine - where you are running the Workspace desktop.

    See the Getting Started guide for LD Library and use the Desktop Session.

  • swasti
    swasti Newcomer

    Workspace is web

  • In that case, you are limited to the options mentioned above. There is no means to download directly from your notebooks to the local drive.

    The codebook environment executes the notebooks in the cloud, and does not have any access to your local filesystem.

  • swasti
    swasti Newcomer

    Not ideal in the current work structure. Any plan to change this and remove the limitations?

  • I don't think so. Allowing direct access to a local filesystem from a process running in the cloud isn't allowed by the browser's security model.