arrow::compute

Function filter

pub fn filter(
    values: &dyn Array,
    predicate: &BooleanArray,
) -> Result<Arc<dyn Array>, ArrowError>
Expand description

Returns a filtered values Array where the corresponding elements of predicate are true.

See also FilterBuilder for more control over the filtering process.

ยงExample

let array = Int32Array::from(vec![5, 6, 7, 8, 9]);
let filter_array = BooleanArray::from(vec![true, false, false, true, false]);
let c = filter(&array, &filter_array).unwrap();
let c = c.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(c, &Int32Array::from(vec![5, 8]));