Getting Started With Google Colab
January 30, 2020
Data Levels of Measurement
February 3, 2020
Show all

Using Kaggle Datasets in Google Colab

Step-by-step —

  1. Create an API key in Kaggle.To do this, go to kaggle.com/ and open your user settings page. 
  2. Next, scroll down to the API access section and click generate to download an API key.  This will download a file called kaggle.json to your computer. You’ll use this file in Colab to access Kaggle datasets and competitions.
  3. Navigate to https://colab.research.google.com/.
  4. Upload your kaggle.json file using the following snippet in a code cell:from google.colab import files files.upload()
  5. Install the kaggle API using !pip install -q kaggle
  6. Move the kaggle.json file into ~/.kaggle, which is where the API client expects your token to be located:!mkdir -p ~/.kaggle !cp kaggle.json ~/.kaggle/
  7. Now you can access datasets using the client, e.g., !kaggle datasets list.
  8. # Copy the stackoverflow data set locally:
  9. !kaggle datasets download -d stackoverflow/stack-overflow-2018-developer-survey

Here’s a complete example notebook of the Colab portion of this process: https://colab.research.google.com/drive/1DofKEdQYaXmDWBzuResXWWvxhLgDeVyl

This example shows uploading the kaggle.json file, the Kaggle API client, and using the Kaggle client to download a dataset.

Amir Masoud Sefidian
Amir Masoud Sefidian
Data Scientist, Researcher, Software Developer

Leave a Reply

Your email address will not be published. Required fields are marked *