Skip to content

Deleting Data

Remove individual datapoints from a dataset collection by specifying their unique identifiers, or delete many at once by selecting an entire time range.

Check out the examples below for common scenarios of deleting data from a collection.

To delete data from a collection, use the delete method. This method accepts a list of datapoint IDs to delete.

from tilebox.datasets import Client
client = Client()
datasets = client.datasets()
collections = datasets.my_custom_dataset.collections()
collection = collections["Sensor-1"]
n_deleted = collection.delete([
"0195c87a-49f6-5ffa-e3cb-92215d057ea6",
"0195c87b-bd0e-3998-05cf-af6538f34957",
])
print(f"Deleted {n_deleted} data points.")
Deleted 2 data points.
  • NotFoundError: raised if one of the data points is not found in the collection. If any of the data points are not found, nothing will be deleted
  • ValueError: raised if one of the specified ids is not a valid UUID

One common way to delete all datapoints in a time interval is to first query it from a collection and then deleting those found datapoints. For this use case it often is a good idea to query the datapoints with skip_data=True to avoid actually loading the data fields, since only the datapoint IDs are required. See skipping data fields for more details.

to_delete = collection.query(temporal_extent=("2023-05-01", "2023-06-01"), skip_data=True)
n_deleted = collection.delete(to_delete)
print(f"Deleted {n_deleted} data points.")
Deleted 104 data points.

Tilebox automatically batches the delete requests for you, so you don’t have to worry about the maximum request size.