polars_core/chunked_array/ops/
bits.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use super::BooleanChunked;

impl BooleanChunked {
    pub fn num_trues(&self) -> usize {
        self.downcast_iter()
            .map(|arr| match arr.validity() {
                None => arr.values().set_bits(),
                Some(validity) => arr.values().num_intersections_with(validity),
            })
            .sum()
    }

    pub fn num_falses(&self) -> usize {
        self.downcast_iter()
            .map(|arr| match arr.validity() {
                None => arr.values().unset_bits(),
                Some(validity) => (!arr.values()).num_intersections_with(validity),
            })
            .sum()
    }
}