Querying Datasets
Deep Lake offers a highly-performant SQL-style query engine for filtering your data.
Last updated
Was this helpful?
Was this helpful?
view = ds.query('Query string')ds_view.save_view(message = 'Samples with monarchs')ds_view = ds.load_view(view_id, optimize = True, num_workers = 2)
for data in ds_view.pytorch():
# Training loop hereds.delete_view(view_id)# Exact match, which generally requires that the sample
# has 1 value, i.e. no lists or multi-dimensional arrays
select * where tensor_name == 'text_value' # If value is numeric
select * where tensor_name == numeric_value # If values is text
select * where contains(tensor_name, 'text_value')select * where contains("tensor-name", 'text_value')
select * where "tensor_name/group_name" == numeric_valueselect * where shape(tensor_name)[dimension_index] > numeric_value
select * where shape(tensor_name)[1] > numeric_value # Second array dimension > valueselect * where contains(tensor_name, 'text_value') limit num_samplesselect * where contains(tensor_name, 'text_value') and NOT contains(tensor_name_2, numeric_value)
select * where contains(tensor_name, 'text_value') or tensor_name_2 == numeric_value
select * where (contains(tensor_name, 'text_value') and shape(tensor_name_2)[dimension_index]>numeric_value) or contains(tensor_name, 'text_value_2')(select * where contains(tensor_name, 'value')) intersect (select * where contains(tensor_name, 'value_2'))
(select * where contains(tensor_name, 'value') limit 100) union (select * where shape(tensor_name)[0] > numeric_value limit 100)# Order by requires that sample is numeric and has 1 value,
# i.e. no lists or multi-dimensional arrays
select * where contains(tensor_name, 'text_value') order by tensor_name ascselect * where all_strict(tensor_name[:,2]>numeric_value)
select * where any(tensor_name[0:6]>numeric_value)select * where any(logical_and(tensor_name_1[:,3]>numeric_value, tensor_name_2 == 'text_value'))select * sample by weight_choice(expression_1: weight_1, expression_2: weight_2, ...)
replace True limit N