These are some common use cases people have when working with Datasets in the Python API.
Before you start
Make sure the client is initialized.
from labelbox import Client
client = Client()
Create a Dataset
To learn how to create a Dataset, see Creating your first project.
Fetch a Dataset
Since a Dataset is a top-level object, you can get a specific Dataset by passing the unique ID of the Dataset to the client. The
get_dataset method will only take a unique ID as an argument.
dataset = client.get_dataset("<dataset_id>")
Fetch multiple Datasets
Below are three examples for fetching multiple datasets using the
a. The code sample below demonstrates how to fetch all Datasets in your account and print the collection of Datasets by unique ID.
for dataset in client.get_datasets():
b. Pass a
where parameter with a comparison operator. Use the
get_datasets method and any of the standard comparison operators (==, !=, >, >=, <, <=) to target a Dataset. Because the
get_datasets method can theoretically return any number of results, it will give you a
PaginatedCollection object over which you can iterate to get your specified Dataset.
from labelbox import Dataset
datasets_x = client.get_datasets(where=Dataset.name == "X")for x in datasets_x:
c. You can also find Datasets by using the
get_datasets method to combine comparisons using logical expressions. Currently the
where clause supports the logical AND operator.
from labelbox import Project
datasets = client.get_datasets(where=(Project.name == "X") & (Project.description == "Y"))
for x in datasets_x:
Was this section helpful? Give your feedback below.