How to Import Kaggle Datasets Directly into Google Colab
Last Updated :
23 May, 2023
In this article, we will see how to import Kaggle Datasets into Google Colab.
Getting Started
Here, we are going to cover two different methods to start working with Colab. In the first method, we will use Kaggle API to download our dataset, and after that, we are good to go to use our dataset. In another method, we manually download from the Kaggle website and use our dataset for our production or analysis data. you first need to log in to your Google account, then go to this link https://colab.research.google.com.
Method 1: Downloading Kaggle Dataset in Google Colab Notebook
Step 1: Open your Google Colab Notebook

Google Colab interface
Step 2: Download and Install the required packages.
pip install opendatasets
pip install pandas

Install open dataset in Colab
Step 3: Visit www.kaggle.com. Go to your profile and click on account.

Download Kaggle token
Step 4: On the following page you will see an API section, where you will find a “Create New API Token” click on it, and it will download a kaggle.json file in which you will get your username and key. we will use username and key in our next step.
Step 5: Import the opendatasets library and download your Kaggle dataset by pasting the link on it.
Python3
import opendatasets as od
import pandas
od.download(
"https://www.kaggle.com/datasets/\
muratkokludataset/acoustic-extinguisher-fire-dataset")
|
Output:
Step 6: Now we are ready to use our dataset.
Python3
import pandas as pds
file =('Acoustic_Extinguisher_Fire_Dataset/\
Acoustic_Extinguisher_Fire_Dataset.xlsx')
newData = pds.read_excel(file)
newData.head()
|
Output:

First 5 rows of the dataset
Method 2: By Installing Kaggle In our Colab Notebook
Step 1: Select any dataset from Kaggle

Kaggle dataset
Step 2: Download Dataset API Token
We will download the Kaggle API token which will be present in Account directory under our Kaggle profile section. The file name for the token will be Kaggle.json

Kaggle token file
To download the dataset
Step 3: Setup the Colab Notebook
To download the dataset into google colab notebook we first have to install kaggle in our local system then we will grant permission kaggle.json file to download file dataset from third party link
- Install the Kaggle library
pip install kaggle
- Make a directory named “.kaggle”
mkdir ~/.kaggle
- Copy the “kaggle.json” into this new directory
cp kaggle.json ~/.kaggle/
- Allocate the required permission for this file.
chmod 600 ~/.kaggle/kaggle.json

Command to install Kaggle API in Colab notebook
Step 4: Download the Dataset into Colab File
To download the dataset into Colab we will use another command followed by the dataset name
Suppose our dataset web link in
https://www.kaggle.com/datasets/gauravduttakiit/cassava-leaf-disease-classification
then we will type
! kaggle datasets download gauravduttakiit/cassava-leaf-disease-classification

Kaggle dataset download command
- For downloading competitions data
Suppose our competition data link is
https://www.kaggle.com/competitions/playground-series-s3e14
then we will type
! kaggle competitions download playground-series-s3e14

Kaggle competition download command
Method 3: By easily downloading the Kaggle dataset.
Step 1: Visit the Kaggle website and Select the Dataset tab.
Step 2: Select any Dataset and Click on the Download.
Step 3: The downloaded file will be in Zip form, Unzip it.
Step 4: Upload Your Dataset file or folder to Google Colab Notebook. On clicking on Upload your folder/file you will get an option to upload your file/ folder as the given image illustrate.
Step 5: Now we have successfully uploaded our dataset on Google Colab Notebook.
Step 5: Now you are ready to use your Kaggle dataset.
Python3
import pandas as pds
file = ('Acoustic_Extinguisher_Fire_Dataset/\
Acoustic_Extinguisher_Fire_Dataset.xlsx')
newData = pds.read_excel(file)
newData.head()
|
Output:

Similar Reads
How to Import Kaggle Datasets Directly into Google Colab
In this article, we will see how to import Kaggle Datasets into Google Colab. Getting Started Here, we are going to cover two different methods to start working with Colab. In the first method, we will use Kaggle API to download our dataset, and after that, we are good to go to use our dataset. In a
3 min read
How to Download Kaggle Datasets into Jupyter Notebook?
In this article, we will see how to Download Kaggle Datasets using Jupyter Notebook. Here, we are going to cover two different methods to start working with Jupyter Notebook. In the first method, we will use Kaggle API to download our dataset, and after that, we are good to go to use our dataset. In
2 min read
How to import datasets using sklearn in PyBrain
In this article, we will discuss how to import datasets using sklearn in PyBrain Dataset: A Dataset is defined as the set of data that is can be used to test, validate, and train on networks. On comparing it with arrays, a dataset is considered more flexible and easy to use. A dataset resembles a 2-
2 min read
How to use datasets.fetch_mldata() in sklearn - Python?
mldata.org does not have an enforced convention for storing data or naming the columns in a data set. The default behavior of this function works well with most of the common cases mentioned below: Data values stored in the column are 'Data’, and target values stored in the column are ‘label’.The fi
2 min read
Guide to deploy containers on Google Cloud Run
Google Cloud Run is one of the fast and scalable solution for your API deployment over secure https connection and can be considered as first choice of every developer. Well firebase is for static websites, right? What if we can deploy Dynamic websites on firebase too? All you need is Cloud Run. Her
3 min read
Different ways to import csv file in Pandas
CSV files are the "comma separated values", these values are separated by commas, this file can be viewed as an Excel file. In Python, Pandas is the most important library coming to data science. We need to deal with huge datasets while analyzing the data, which usually can be in CSV file format. Le
3 min read
How to Use Google Bard with Python
If you are a data enthusiast or aspiring data scientist and you are searching for amazing methods to showcase your findings, look no further than Google Bard. Google Bard is an AI chatbot developed by Google AI. It is a large language model chatbot based on the LaMDA family of LLMs. It helps to deve
6 min read
How to Automate Google Sheets with Python?
In this article, we will discuss how to Automate Google Sheets with Python. Pygsheets is a simple python library that can be used to automate Google Sheets through the Google Sheets API. An example use of this library would be to automate the plotting of graphs based on some data in CSV files that w
4 min read
How to Scrape Web Data from Google using Python?
Prerequisites: Python Requests, Implementing Web Scraping in Python with BeautifulSoup Web scraping is a technique to fetch data from websites. While surfing on the web, many websites don’t allow the user to save data for personal use. One way is to manually copy-paste the data, which both tedious a
2 min read
PyBrain - Importing Data For Datasets
In this article, we will learn how to import data for datasets in PyBrain. Datasets are the data to be given to test, validate and train on networks. The type of dataset to be used depends on the tasks that we are going to do with Machine Learning. The most commonly used datasets that Pybrain suppor
2 min read
How to Create Delta Table in Databricks Using PySpark
An open-source storage layer called Delta Lake gives data lakes scalability, performance, and dependability. It offers a transactional layer on top of cloud storage and lets you handle massive volumes of data in a data lake. This post will explain how to use PySpark to generate a Delta table in Data
4 min read
How to use a DataLoader in PyTorch?
Operating with large datasets requires loading them into memory all at once. In most cases, we face a memory outage due to the limited amount of memory available in the system. Also, the programs tend to run slowly due to heavy datasets loaded once. PyTorch offers a solution for parallelizing the da
2 min read
How to Save Pandas Dataframe as gzip/zip File?
Pandas is an open-source library that is built on top of NumPy library. It is a Python package that offers various data structures and operations for manipulating numerical data and time series. It is mainly popular for importing and analyzing data much easier. Pandas is fast and it has high-perform
2 min read
How To Convert Sklearn Dataset To Pandas Dataframe In Python
In this article, we look at how to convert sklearn dataset to a pandas dataframe in Python. Sklearn and pandas are python libraries that are used widely for data science and machine learning operations. Pandas is majorly focused on data processing, manipulation, cleaning, and visualization whereas s
3 min read
How to load a TSV file into a Pandas DataFrame?
In this article, we will discuss how to load a TSV file into a Pandas Dataframe. The idea is extremely simple we only have to first import all the required libraries and then load the data set by using various methods in Python. Dataset Used: data.tsv Using read_csv() to load a TSV file into a Panda
1 min read
Using Google Sheets as Database in Python
In this article we'll be discussing how we can use Google Sheets to run like a database for any Python file. Google Spreadsheets:Google Spreadsheets is free online web based application that resembles Microsoft Excel. You can use it to create and edit tables for various projects such as Contact Lis
4 min read
Store Google Sheets data into SQLite Database using Python
In this article, we are going to store google sheets data into a database using python. The first step is to enable the API and to create the credentials, so let's get stared. Enabling the APIs and creating the credentialsGo to Marketplace in Cloud Console.Click on ENABLE APIS AND SERVICESThen Searc
5 min read
Get list of files and folders in Google Drive storage using Python
In this article, we are going to have a look at how can we get a list of files (or folders) stored in our Google Drive cloud storage using Google Drive API in Python. It is a REST API that allows you to leverage Google Drive storage from within your app or program. So, let's create a simple Python s
4 min read
How to Convert JSON to Excel in Python
JSON (JavaScript Object Notation) is a widely used data format that is both easy to read and write for humans and simple for machines to parse and generate. However, there may be times when we need to convert this JSON data into an Excel spreadsheet for analysis or reporting. In this article, we'll
3 min read