Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting Data from google colab to local machine

How to export data frames which are created in google colab to your local machine?

I have cleaned a data set on google colab. Now I want to export the data frame to my local machine. df.to_csv is saving file to the virtual machine and not my local machine.

like image 534
Pranathi Avatar asked Mar 20 '18 21:03

Pranathi


People also ask

How do I save a colab file to local?

Downloading files from Colab to local file system using Python code: The download method of the files object can be used to download any file from colab to your local drive. The download progress is displayed, and once the download completes, you can choose where to save it in your local machine.


2 Answers

Try this

from google.colab import files files.download("data.csv") 

Update(Sep 2018): now it's even easier

  • open the left pane
  • select 'Files' tab
  • click 'Refresh'
  • right click the file, then download

Update (Jan 2020): the UI changes

  • click on the folder icon on the left pane (3rd icon)
  • click 'Refresh'
  • right click the file, then download
like image 56
korakot Avatar answered Sep 20 '22 06:09

korakot


Try this:

First you can save the file using pandas to_csv functionality later on you can download that file using google colab files functionality.

from google.colab import files df.to_csv('filename.csv')  files.download('filename.csv') 
like image 26
Abhishek Thombre Avatar answered Sep 21 '22 06:09

Abhishek Thombre