polars_ops/chunked_array/
mod.rs1#[cfg(feature = "dtype-array")]
2pub mod array;
3mod binary;
4pub mod list;
5#[cfg(feature = "dtype-map")]
6pub mod map;
7#[cfg(feature = "propagate_nans")]
8pub mod nan_propagating_aggregate;
9#[cfg(feature = "peaks")]
10pub mod peaks;
11mod scatter;
12pub mod strings;
13mod sum;
14#[cfg(feature = "top_k")]
15mod top_k;
16
17#[cfg(feature = "mode")]
18pub mod mode;
19
20#[cfg(feature = "cov")]
21pub mod cov;
22pub(crate) mod gather;
23#[cfg(feature = "gather")]
24pub mod gather_skip_nulls;
25#[cfg(feature = "hist")]
26mod hist;
27#[cfg(feature = "repeat_by")]
28mod repeat_by;
29
30pub use binary::*;
31#[cfg(feature = "chunked_ids")]
32pub use gather::*;
33#[cfg(feature = "hist")]
34pub use hist::*;
35pub use list::*;
36#[cfg(feature = "dtype-map")]
37pub use map::*;
38#[allow(unused_imports)]
39use polars_core::prelude::*;
40#[cfg(feature = "repeat_by")]
41pub use repeat_by::*;
42pub use scatter::ChunkedSet;
43pub use strings::*;
44#[cfg(feature = "top_k")]
45pub use top_k::*;
46
47#[allow(unused_imports)]
48use crate::prelude::*;
49
50pub(crate) fn saturating_usize(n: u64) -> usize {
52 usize::try_from(n).unwrap_or(usize::MAX)
53}
54
55pub(crate) fn count_as_i64(n: &Column, len: usize) -> PolarsResult<Column> {
58 let n = match n.as_scalar_column() {
59 Some(sc) if n.len() == len && len > 1 => &sc.as_single_value_series().into_column(),
60 _ => n,
61 };
62 match n.dtype() {
63 DataType::UInt64 => n.try_apply_unary_elementwise(|n| {
64 Ok(
65 arity::unary_elementwise_values::<_, Int64Type, _>(n.u64()?, |v| {
66 v.min(i64::MAX as u64) as i64
67 })
68 .into_series(),
69 )
70 }),
71 _ => n.strict_cast(&DataType::Int64),
72 }
73}