Question & Answer
Question
How do you save the DataFrame for a Watson Studio Project Notebook Asset to Cloud Object Storage?
Answer
Answer
In a Watson Studio Project Notebook, you can use the project_lib library to store a DataFrame to a Cloud Object Storage file as illustrated by the following code:
from project_lib import Project
project = Project(sc,"<my_project_id>","<my_project_token>")
df = dataframe.DataFrame([[1, 2], [3, 4]], columns=list(';AB';))
df
project.save_data(file_name = "mypanda.csv",data = df.to_csv(index=False))
Here is the contents of the mypanda.csv file in the project';s Cloud Object Storage bucket:
A B
1 2
3 4
The Cloud Object Storage bucket is provided in the project';s Settings tab under Storage.
For more information, see the Save data to the object storage information within the Watson Studio service documentation.
For more information, see the Save data to the object storage information within the Watson Studio service documentation.
Notes:
- You can obtain the my_project_id parameter from the address bar after you open the notebook. The following URL shows where the my_project_id is located in a notebook';s URL:
https://dataplatform.cloud.ibm.com/analytics/notebooks/v2/<my_project_id>=####&context=wdp - The my_project_token parameter is generated and listed on the project';s Settings tab in the Access Token list as shown in the following image:
Click the 3 dots in the Actions column to view the token.
[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSCLA9","label":"IBM Watson Studio Cloud"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]
Was this topic helpful?
Document Information
Modified date:
01 August 2019
UID
ibm1KB0011628