-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
array.rs
85 lines (69 loc) · 2.01 KB
/
array.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use polars::prelude::*;
use pyo3::pymethods;
use crate::expr::PyExpr;
#[pymethods]
impl PyExpr {
fn arr_max(&self) -> Self {
self.inner.clone().arr().max().into()
}
fn arr_min(&self) -> Self {
self.inner.clone().arr().min().into()
}
fn arr_sum(&self) -> Self {
self.inner.clone().arr().sum().into()
}
fn arr_unique(&self, maintain_order: bool) -> Self {
if maintain_order {
self.inner.clone().arr().unique_stable().into()
} else {
self.inner.clone().arr().unique().into()
}
}
fn arr_to_list(&self) -> Self {
self.inner.clone().arr().to_list().into()
}
fn arr_all(&self) -> Self {
self.inner.clone().arr().all().into()
}
fn arr_any(&self) -> Self {
self.inner.clone().arr().any().into()
}
fn arr_sort(&self, descending: bool, nulls_last: bool) -> Self {
self.inner
.clone()
.arr()
.sort(SortOptions {
descending,
nulls_last,
..Default::default()
})
.into()
}
fn arr_reverse(&self) -> Self {
self.inner.clone().arr().reverse().into()
}
fn arr_arg_min(&self) -> Self {
self.inner.clone().arr().arg_min().into()
}
fn arr_arg_max(&self) -> Self {
self.inner.clone().arr().arg_max().into()
}
fn arr_get(&self, index: PyExpr) -> Self {
self.inner.clone().arr().get(index.inner).into()
}
fn arr_join(&self, separator: PyExpr, ignore_nulls: bool) -> Self {
self.inner
.clone()
.arr()
.join(separator.inner, ignore_nulls)
.into()
}
#[cfg(feature = "is_in")]
fn arr_contains(&self, other: PyExpr) -> Self {
self.inner.clone().arr().contains(other.inner).into()
}
#[cfg(feature = "array_count")]
fn arr_count_matches(&self, expr: PyExpr) -> Self {
self.inner.clone().arr().count_matches(expr.inner).into()
}
}