datasetdata-science

How can I download a kaggle dataset on my Colab notebook?


Can someone help me with downloading Kaggle dataset on my Colab Notebook? I am new to Colab.


Solution

  • You can use the following method to download any kaggle dataset to your Colab notebook.

    1. First, you have to create an API key in Kaggle.
    2. Go to kaggle.com and open your user settings page.
    3. From the API access section download an API key.
    4. A file called kaggle.json will be downloaded to your computer.
    5. Now open your Colab notebook and copy the following snippet to a cell.

      from google.colab import files

      files.upload()

      After executing this upload the kaggle.json file.

    6. Install the kaggle API using !pip install -q kaggle and move kaggle.json file to ~/.kaggle

      !mkdir -p ~/.kaggle

      !cp kaggle.json ~/.kaggle/

    7. Now you can download the dataset to your Colab notebook by copying the API command of the dataset that you want to download. For example:

      !kaggle competitions download -c titanic

    The dataset should get downloaded to your notebook after this. Happy Coding.