Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hello DSS community,
could it be possible to download a panda's dataset from a python notebook into a local computer?
Without doing clicking into the button shown on the picture
thank you :))
Hi @saraa1 ,
This is surely possible, as this is a pandas dataframe you can utilize the pandas API to do this.
For example, if you would like to download this dataframe as a csv file, you can use:
df.to_csv('out.csv')
You can find this file at
<YOUR_DATA_DIR>/jupyter-run/dkuworkdirs/<YOUR_PROJECT_KEY>/<NAME_OF_NOTEBOOK_WITH_ADDED_ID>/out.csv
- Elias
Hello Elias,
Thank you for your answer,
but this does not work on a jupyter notebook on DSS, while I'm not admin,
maybe, I could try to save the file on DSS folders !!! This could be also a solution and a way to keep me on DSS environment as well,
but how to do so then ?
Hello @saraa1,
Assuming you want to save the data frame without clicking a button in CSV format, you can use javascript to open the link client-side. Please refer to the code example below:
import base64
from io import BytesIO
from IPython.display import Javascript
def save_df( df, filename = "data.csv"):
csv = df.to_csv()
b64 = base64.b64encode(csv.encode())
payload = b64.decode()
url="data:text/csv;base64,{payload}".format(payload=payload)
display(Javascript('window.open("{url}");'.format(url=url)))
save_df(mydataset_df)
Hope this is what you were looking for.
Best,
Vitaliy