How to Use Your Dataset in Google Colab Easily via Google Drive

Mehmet Emin Yıldırım
Analytics Vidhya
Published in
2 min readApr 15, 2020

The easy way to use your datasets in Google Colab

1. Create a Folder in Google Drive

In this example, we created a folder named “colab” in the main (My Drive) directory.

2. Upload Your Dataset

Here, we uploaded our dataset to our “colab” folder.

3. Create or Open a Colab Notebook

Here, we created a new colab notebook.

4. Mount Your Drive

Use the code below to mount your drive:

# mount
from google.colab import drive
drive.mount('/content/drive')

Now, we need to get the authorization code so, we click on the URL given and complete the authorization steps.

After completing all steps, We finally get our authorization code:

We copied and pasted the authorization code to the input field and then, we pressed Enter.

Note: The mounting step should be repeated in every session.

5. Read Your Dataset from Google Drive

We had already created a folder named “colab” and we had uploaded our dataset into it. For this reason, we need to use the path below to read our dataset:

"/content/drive/My Drive/colab/dataset.csv"

In this example, we read our dataset using pandas.

6. Notes

  • The mounting step should be repeated in every session.

--

--