Skip to content Skip to sidebar Skip to footer

How Can I Download A Pandas Dataframe In Google Colab?

I have been stuck on how to download a pandas DataFrame into my local disk (or onto Google Drive) after creating it in Google Colab. I have tried converting it to bytes, a string (

Solution 1:

Maybe something like this.

from google.colab import files

df.to_csv('df.csv')
files.download('df.csv')

Solution 2:

For google colab, i recommend use Pydrive. Your answer can be found in here How to download file created in Colaboratory workspace?

edit: just change filename.csv to filename.zip or filename.blabla in lines

uploaded = drive.CreateFile({'title': 'filename.csv'})
uploaded.SetContentFile('filename.csv')

why? because this line

uploaded.SetContentFile('filename.csv')

auto set format for you content file, so you don't need to converter it to String or Byte.


Post a Comment for "How Can I Download A Pandas Dataframe In Google Colab?"