Home > Blockchain >  Is it possible to download an object as a file from google colab WITHOUT first saving it as a file t
Is it possible to download an object as a file from google colab WITHOUT first saving it as a file t

Time:10-22

I'm trying to download a pandas dataframe directly from colab's memory INSTEAD of saving that dataframe to drive as a csv then using the files library to download that file.

import pandas as pd
import numpy as np

data = pd.DataFrame(np.random.random(10))

data.to_csv()

This block of code generates a formatted example I just need something that will give me a dialog box so I can save that object locally.

The reason behind this is I'm developing a shared notebook that others will use to generate data and I don't want have the users saving all kinds of stuff to my drive. Is what I'm asking for currently possible?

CodePudding user response:

Yes, there are several options:

  1. Use the google.colab.files module to download like so:
    from google.colab import files
    files.download('csv')
  1. Right click on the file in the file browser and select download like so:

enter image description here

  • Related