polars-df 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -0
- data/Cargo.lock +353 -237
- data/Cargo.toml +0 -3
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/ext/polars/Cargo.toml +17 -6
- data/ext/polars/src/batched_csv.rs +6 -7
- data/ext/polars/src/conversion/anyvalue.rs +185 -0
- data/ext/polars/src/conversion/chunked_array.rs +140 -0
- data/ext/polars/src/{conversion.rs → conversion/mod.rs} +268 -347
- data/ext/polars/src/dataframe.rs +96 -116
- data/ext/polars/src/expr/array.rs +74 -0
- data/ext/polars/src/expr/categorical.rs +8 -1
- data/ext/polars/src/expr/datetime.rs +22 -56
- data/ext/polars/src/expr/general.rs +124 -37
- data/ext/polars/src/expr/list.rs +52 -4
- data/ext/polars/src/expr/meta.rs +48 -0
- data/ext/polars/src/expr/rolling.rs +16 -10
- data/ext/polars/src/expr/string.rs +68 -17
- data/ext/polars/src/expr/struct.rs +8 -4
- data/ext/polars/src/functions/aggregation.rs +6 -0
- data/ext/polars/src/functions/lazy.rs +103 -48
- data/ext/polars/src/functions/meta.rs +45 -1
- data/ext/polars/src/functions/range.rs +5 -10
- data/ext/polars/src/functions/string_cache.rs +14 -0
- data/ext/polars/src/{lazyframe.rs → lazyframe/mod.rs} +166 -41
- data/ext/polars/src/lib.rs +245 -187
- data/ext/polars/src/map/dataframe.rs +1 -1
- data/ext/polars/src/map/mod.rs +2 -2
- data/ext/polars/src/map/series.rs +6 -6
- data/ext/polars/src/object.rs +0 -30
- data/ext/polars/src/on_startup.rs +32 -0
- data/ext/polars/src/series/aggregation.rs +23 -0
- data/ext/polars/src/series/construction.rs +1 -1
- data/ext/polars/src/series/export.rs +2 -2
- data/ext/polars/src/{series.rs → series/mod.rs} +45 -21
- data/ext/polars/src/series/{set_at_idx.rs → scatter.rs} +18 -18
- data/ext/polars/src/utils.rs +1 -1
- data/lib/polars/array_expr.rb +449 -0
- data/lib/polars/array_name_space.rb +346 -0
- data/lib/polars/cat_expr.rb +24 -0
- data/lib/polars/cat_name_space.rb +75 -0
- data/lib/polars/config.rb +2 -2
- data/lib/polars/data_frame.rb +248 -108
- data/lib/polars/data_types.rb +195 -29
- data/lib/polars/date_time_expr.rb +41 -24
- data/lib/polars/date_time_name_space.rb +12 -12
- data/lib/polars/exceptions.rb +12 -1
- data/lib/polars/expr.rb +1080 -195
- data/lib/polars/functions/aggregation/horizontal.rb +246 -0
- data/lib/polars/functions/aggregation/vertical.rb +282 -0
- data/lib/polars/functions/as_datatype.rb +248 -0
- data/lib/polars/functions/col.rb +47 -0
- data/lib/polars/functions/eager.rb +182 -0
- data/lib/polars/functions/lazy.rb +1280 -0
- data/lib/polars/functions/len.rb +49 -0
- data/lib/polars/functions/lit.rb +35 -0
- data/lib/polars/functions/random.rb +16 -0
- data/lib/polars/functions/range/date_range.rb +103 -0
- data/lib/polars/functions/range/int_range.rb +51 -0
- data/lib/polars/functions/repeat.rb +144 -0
- data/lib/polars/functions/whenthen.rb +27 -0
- data/lib/polars/functions.rb +29 -416
- data/lib/polars/group_by.rb +3 -3
- data/lib/polars/io.rb +21 -28
- data/lib/polars/lazy_frame.rb +390 -76
- data/lib/polars/list_expr.rb +152 -6
- data/lib/polars/list_name_space.rb +102 -0
- data/lib/polars/meta_expr.rb +175 -7
- data/lib/polars/series.rb +557 -59
- data/lib/polars/sql_context.rb +1 -1
- data/lib/polars/string_cache.rb +75 -0
- data/lib/polars/string_expr.rb +412 -96
- data/lib/polars/string_name_space.rb +4 -4
- data/lib/polars/struct_expr.rb +1 -1
- data/lib/polars/struct_name_space.rb +1 -1
- data/lib/polars/testing.rb +507 -0
- data/lib/polars/utils.rb +64 -20
- data/lib/polars/version.rb +1 -1
- data/lib/polars.rb +15 -2
- metadata +40 -9
- data/lib/polars/lazy_functions.rb +0 -1197
@@ -1,3 +1,5 @@
|
|
1
|
+
use std::ops::Neg;
|
2
|
+
|
1
3
|
use magnus::{prelude::*, value::Opaque, IntoValue, RArray, Ruby, Value};
|
2
4
|
use polars::lazy::dsl;
|
3
5
|
use polars::prelude::*;
|
@@ -11,55 +13,67 @@ use crate::utils::reinterpret;
|
|
11
13
|
use crate::{RbExpr, RbResult};
|
12
14
|
|
13
15
|
impl RbExpr {
|
14
|
-
pub fn add(&self, rhs: &
|
16
|
+
pub fn add(&self, rhs: &Self) -> RbResult<Self> {
|
15
17
|
Ok(dsl::binary_expr(self.inner.clone(), Operator::Plus, rhs.inner.clone()).into())
|
16
18
|
}
|
17
19
|
|
18
|
-
pub fn sub(&self, rhs: &
|
20
|
+
pub fn sub(&self, rhs: &Self) -> RbResult<Self> {
|
19
21
|
Ok(dsl::binary_expr(self.inner.clone(), Operator::Minus, rhs.inner.clone()).into())
|
20
22
|
}
|
21
23
|
|
22
|
-
pub fn mul(&self, rhs: &
|
24
|
+
pub fn mul(&self, rhs: &Self) -> RbResult<Self> {
|
23
25
|
Ok(dsl::binary_expr(self.inner.clone(), Operator::Multiply, rhs.inner.clone()).into())
|
24
26
|
}
|
25
27
|
|
26
|
-
pub fn truediv(&self, rhs: &
|
28
|
+
pub fn truediv(&self, rhs: &Self) -> RbResult<Self> {
|
27
29
|
Ok(dsl::binary_expr(self.inner.clone(), Operator::TrueDivide, rhs.inner.clone()).into())
|
28
30
|
}
|
29
31
|
|
30
|
-
pub fn _mod(&self, rhs: &
|
32
|
+
pub fn _mod(&self, rhs: &Self) -> RbResult<Self> {
|
31
33
|
Ok(dsl::binary_expr(self.inner.clone(), Operator::Modulus, rhs.inner.clone()).into())
|
32
34
|
}
|
33
35
|
|
34
|
-
pub fn floordiv(&self, rhs: &
|
36
|
+
pub fn floordiv(&self, rhs: &Self) -> RbResult<Self> {
|
35
37
|
Ok(dsl::binary_expr(self.inner.clone(), Operator::FloorDivide, rhs.inner.clone()).into())
|
36
38
|
}
|
37
39
|
|
40
|
+
pub fn neg(&self) -> RbResult<Self> {
|
41
|
+
Ok(self.inner.clone().neg().into())
|
42
|
+
}
|
43
|
+
|
38
44
|
pub fn to_str(&self) -> String {
|
39
45
|
format!("{:?}", self.inner)
|
40
46
|
}
|
41
47
|
|
42
|
-
pub fn eq(&self, other: &
|
48
|
+
pub fn eq(&self, other: &Self) -> Self {
|
43
49
|
self.clone().inner.eq(other.inner.clone()).into()
|
44
50
|
}
|
45
51
|
|
46
|
-
pub fn
|
52
|
+
pub fn eq_missing(&self, other: &Self) -> Self {
|
53
|
+
self.inner.clone().eq_missing(other.inner.clone()).into()
|
54
|
+
}
|
55
|
+
|
56
|
+
pub fn neq(&self, other: &Self) -> Self {
|
47
57
|
self.clone().inner.neq(other.inner.clone()).into()
|
48
58
|
}
|
49
59
|
|
50
|
-
pub fn
|
60
|
+
pub fn neq_missing(&self, other: &Self) -> Self {
|
61
|
+
self.inner.clone().neq_missing(other.inner.clone()).into()
|
62
|
+
}
|
63
|
+
|
64
|
+
pub fn gt(&self, other: &Self) -> Self {
|
51
65
|
self.clone().inner.gt(other.inner.clone()).into()
|
52
66
|
}
|
53
67
|
|
54
|
-
pub fn gt_eq(&self, other: &
|
68
|
+
pub fn gt_eq(&self, other: &Self) -> Self {
|
55
69
|
self.clone().inner.gt_eq(other.inner.clone()).into()
|
56
70
|
}
|
57
71
|
|
58
|
-
pub fn lt_eq(&self, other: &
|
72
|
+
pub fn lt_eq(&self, other: &Self) -> Self {
|
59
73
|
self.clone().inner.lt_eq(other.inner.clone()).into()
|
60
74
|
}
|
61
75
|
|
62
|
-
pub fn lt(&self, other: &
|
76
|
+
pub fn lt(&self, other: &Self) -> Self {
|
63
77
|
self.clone().inner.lt(other.inner.clone()).into()
|
64
78
|
}
|
65
79
|
|
@@ -67,7 +81,7 @@ impl RbExpr {
|
|
67
81
|
self.clone().inner.alias(&name).into()
|
68
82
|
}
|
69
83
|
|
70
|
-
pub fn
|
84
|
+
pub fn not_(&self) -> Self {
|
71
85
|
self.clone().inner.not().into()
|
72
86
|
}
|
73
87
|
|
@@ -151,23 +165,78 @@ impl RbExpr {
|
|
151
165
|
self.clone().inner.implode().into()
|
152
166
|
}
|
153
167
|
|
154
|
-
pub fn quantile(
|
155
|
-
&self,
|
156
|
-
quantile: &RbExpr,
|
157
|
-
interpolation: Wrap<QuantileInterpolOptions>,
|
158
|
-
) -> Self {
|
168
|
+
pub fn quantile(&self, quantile: &Self, interpolation: Wrap<QuantileInterpolOptions>) -> Self {
|
159
169
|
self.clone()
|
160
170
|
.inner
|
161
171
|
.quantile(quantile.inner.clone(), interpolation.0)
|
162
172
|
.into()
|
163
173
|
}
|
164
174
|
|
175
|
+
pub fn cut(
|
176
|
+
&self,
|
177
|
+
breaks: Vec<f64>,
|
178
|
+
labels: Option<Vec<String>>,
|
179
|
+
left_closed: bool,
|
180
|
+
include_breaks: bool,
|
181
|
+
) -> Self {
|
182
|
+
self.inner
|
183
|
+
.clone()
|
184
|
+
.cut(breaks, labels, left_closed, include_breaks)
|
185
|
+
.into()
|
186
|
+
}
|
187
|
+
|
188
|
+
pub fn qcut(
|
189
|
+
&self,
|
190
|
+
probs: Vec<f64>,
|
191
|
+
labels: Option<Vec<String>>,
|
192
|
+
left_closed: bool,
|
193
|
+
allow_duplicates: bool,
|
194
|
+
include_breaks: bool,
|
195
|
+
) -> Self {
|
196
|
+
self.inner
|
197
|
+
.clone()
|
198
|
+
.qcut(probs, labels, left_closed, allow_duplicates, include_breaks)
|
199
|
+
.into()
|
200
|
+
}
|
201
|
+
|
202
|
+
pub fn qcut_uniform(
|
203
|
+
&self,
|
204
|
+
n_bins: usize,
|
205
|
+
labels: Option<Vec<String>>,
|
206
|
+
left_closed: bool,
|
207
|
+
allow_duplicates: bool,
|
208
|
+
include_breaks: bool,
|
209
|
+
) -> Self {
|
210
|
+
self.inner
|
211
|
+
.clone()
|
212
|
+
.qcut_uniform(
|
213
|
+
n_bins,
|
214
|
+
labels,
|
215
|
+
left_closed,
|
216
|
+
allow_duplicates,
|
217
|
+
include_breaks,
|
218
|
+
)
|
219
|
+
.into()
|
220
|
+
}
|
221
|
+
|
222
|
+
pub fn rle(&self) -> Self {
|
223
|
+
self.inner.clone().rle().into()
|
224
|
+
}
|
225
|
+
|
226
|
+
pub fn rle_id(&self) -> Self {
|
227
|
+
self.inner.clone().rle_id().into()
|
228
|
+
}
|
229
|
+
|
165
230
|
pub fn agg_groups(&self) -> Self {
|
166
|
-
self.clone().
|
231
|
+
self.inner.clone().agg_groups().into()
|
167
232
|
}
|
168
233
|
|
169
234
|
pub fn count(&self) -> Self {
|
170
|
-
self.clone().
|
235
|
+
self.inner.clone().count().into()
|
236
|
+
}
|
237
|
+
|
238
|
+
pub fn len(&self) -> Self {
|
239
|
+
self.inner.clone().len().into()
|
171
240
|
}
|
172
241
|
|
173
242
|
pub fn value_counts(&self, multithreaded: bool, sorted: bool) -> Self {
|
@@ -243,14 +312,14 @@ impl RbExpr {
|
|
243
312
|
self.clone().inner.arg_min().into()
|
244
313
|
}
|
245
314
|
|
246
|
-
pub fn search_sorted(&self, element: &
|
315
|
+
pub fn search_sorted(&self, element: &Self, side: Wrap<SearchSortedSide>) -> Self {
|
247
316
|
self.inner
|
248
317
|
.clone()
|
249
318
|
.search_sorted(element.inner.clone(), side.0)
|
250
319
|
.into()
|
251
320
|
}
|
252
321
|
|
253
|
-
pub fn gather(&self, idx: &
|
322
|
+
pub fn gather(&self, idx: &Self) -> Self {
|
254
323
|
self.clone().inner.gather(idx.inner.clone()).into()
|
255
324
|
}
|
256
325
|
|
@@ -276,7 +345,7 @@ impl RbExpr {
|
|
276
345
|
out.into()
|
277
346
|
}
|
278
347
|
|
279
|
-
pub fn fill_null(&self, expr: &
|
348
|
+
pub fn fill_null(&self, expr: &Self) -> Self {
|
280
349
|
self.clone().inner.fill_null(expr.inner.clone()).into()
|
281
350
|
}
|
282
351
|
|
@@ -297,7 +366,7 @@ impl RbExpr {
|
|
297
366
|
.into())
|
298
367
|
}
|
299
368
|
|
300
|
-
pub fn fill_nan(&self, expr: &
|
369
|
+
pub fn fill_nan(&self, expr: &Self) -> Self {
|
301
370
|
self.inner.clone().fill_nan(expr.inner.clone()).into()
|
302
371
|
}
|
303
372
|
|
@@ -309,7 +378,7 @@ impl RbExpr {
|
|
309
378
|
self.inner.clone().drop_nans().into()
|
310
379
|
}
|
311
380
|
|
312
|
-
pub fn filter(&self, predicate: &
|
381
|
+
pub fn filter(&self, predicate: &Self) -> Self {
|
313
382
|
self.clone().inner.filter(predicate.inner.clone()).into()
|
314
383
|
}
|
315
384
|
|
@@ -345,11 +414,11 @@ impl RbExpr {
|
|
345
414
|
self.clone().inner.explode().into()
|
346
415
|
}
|
347
416
|
|
348
|
-
pub fn gather_every(&self, n: usize) -> Self {
|
417
|
+
pub fn gather_every(&self, n: usize, offset: usize) -> Self {
|
349
418
|
self.clone()
|
350
419
|
.inner
|
351
420
|
.map(
|
352
|
-
move |s: Series| Ok(Some(s.gather_every(n))),
|
421
|
+
move |s: Series| Ok(Some(s.gather_every(n, offset))),
|
353
422
|
GetOutput::same_type(),
|
354
423
|
)
|
355
424
|
.with_fmt("gather_every")
|
@@ -364,14 +433,14 @@ impl RbExpr {
|
|
364
433
|
self.clone().inner.head(n).into()
|
365
434
|
}
|
366
435
|
|
367
|
-
pub fn slice(&self, offset: &
|
436
|
+
pub fn slice(&self, offset: &Self, length: &Self) -> Self {
|
368
437
|
self.inner
|
369
438
|
.clone()
|
370
439
|
.slice(offset.inner.clone(), length.inner.clone())
|
371
440
|
.into()
|
372
441
|
}
|
373
442
|
|
374
|
-
pub fn append(&self, other: &
|
443
|
+
pub fn append(&self, other: &Self, upcast: bool) -> Self {
|
375
444
|
self.inner
|
376
445
|
.clone()
|
377
446
|
.append(other.inner.clone(), upcast)
|
@@ -473,27 +542,27 @@ impl RbExpr {
|
|
473
542
|
Ok(self.clone().inner.over(partition_by).into())
|
474
543
|
}
|
475
544
|
|
476
|
-
pub fn _and(&self, expr: &
|
545
|
+
pub fn _and(&self, expr: &Self) -> Self {
|
477
546
|
self.clone().inner.and(expr.inner.clone()).into()
|
478
547
|
}
|
479
548
|
|
480
|
-
pub fn _xor(&self, expr: &
|
549
|
+
pub fn _xor(&self, expr: &Self) -> Self {
|
481
550
|
self.clone().inner.xor(expr.inner.clone()).into()
|
482
551
|
}
|
483
552
|
|
484
|
-
pub fn _or(&self, expr: &
|
553
|
+
pub fn _or(&self, expr: &Self) -> Self {
|
485
554
|
self.clone().inner.or(expr.inner.clone()).into()
|
486
555
|
}
|
487
556
|
|
488
|
-
pub fn is_in(&self, expr: &
|
557
|
+
pub fn is_in(&self, expr: &Self) -> Self {
|
489
558
|
self.clone().inner.is_in(expr.inner.clone()).into()
|
490
559
|
}
|
491
560
|
|
492
|
-
pub fn repeat_by(&self, by: &
|
561
|
+
pub fn repeat_by(&self, by: &Self) -> Self {
|
493
562
|
self.clone().inner.repeat_by(by.inner.clone()).into()
|
494
563
|
}
|
495
564
|
|
496
|
-
pub fn pow(&self, exponent: &
|
565
|
+
pub fn pow(&self, exponent: &Self) -> Self {
|
497
566
|
self.clone().inner.pow(exponent.inner.clone()).into()
|
498
567
|
}
|
499
568
|
|
@@ -525,7 +594,7 @@ impl RbExpr {
|
|
525
594
|
map_single(self, lambda, output_type, agg_list)
|
526
595
|
}
|
527
596
|
|
528
|
-
pub fn dot(&self, other: &
|
597
|
+
pub fn dot(&self, other: &Self) -> Self {
|
529
598
|
self.inner.clone().dot(other.inner.clone()).into()
|
530
599
|
}
|
531
600
|
|
@@ -562,7 +631,7 @@ impl RbExpr {
|
|
562
631
|
self.inner.clone().upper_bound().into()
|
563
632
|
}
|
564
633
|
|
565
|
-
pub fn cumulative_eval(&self, expr: &
|
634
|
+
pub fn cumulative_eval(&self, expr: &Self, min_periods: usize, parallel: bool) -> Self {
|
566
635
|
self.inner
|
567
636
|
.clone()
|
568
637
|
.cumulative_eval(expr.inner.clone(), min_periods, parallel)
|
@@ -744,4 +813,22 @@ impl RbExpr {
|
|
744
813
|
};
|
745
814
|
self.inner.clone().set_sorted_flag(is_sorted).into()
|
746
815
|
}
|
816
|
+
|
817
|
+
pub fn replace(
|
818
|
+
&self,
|
819
|
+
old: &Self,
|
820
|
+
new: &Self,
|
821
|
+
default: Option<&Self>,
|
822
|
+
return_dtype: Option<Wrap<DataType>>,
|
823
|
+
) -> Self {
|
824
|
+
self.inner
|
825
|
+
.clone()
|
826
|
+
.replace(
|
827
|
+
old.inner.clone(),
|
828
|
+
new.inner.clone(),
|
829
|
+
default.map(|e| e.inner.clone()),
|
830
|
+
return_dtype.map(|dt| dt.0),
|
831
|
+
)
|
832
|
+
.into()
|
833
|
+
}
|
747
834
|
}
|
data/ext/polars/src/expr/list.rs
CHANGED
@@ -7,6 +7,14 @@ use crate::conversion::Wrap;
|
|
7
7
|
use crate::{RbExpr, RbResult};
|
8
8
|
|
9
9
|
impl RbExpr {
|
10
|
+
pub fn list_all(&self) -> Self {
|
11
|
+
self.inner.clone().list().all().into()
|
12
|
+
}
|
13
|
+
|
14
|
+
pub fn list_any(&self) -> Self {
|
15
|
+
self.inner.clone().list().any().into()
|
16
|
+
}
|
17
|
+
|
10
18
|
pub fn list_arg_max(&self) -> Self {
|
11
19
|
self.inner.clone().list().arg_max().into()
|
12
20
|
}
|
@@ -47,11 +55,11 @@ impl RbExpr {
|
|
47
55
|
self.inner.clone().list().get(index.inner.clone()).into()
|
48
56
|
}
|
49
57
|
|
50
|
-
pub fn list_join(&self, separator: &RbExpr) -> Self {
|
58
|
+
pub fn list_join(&self, separator: &RbExpr, ignore_nulls: bool) -> Self {
|
51
59
|
self.inner
|
52
60
|
.clone()
|
53
61
|
.list()
|
54
|
-
.join(separator.inner.clone())
|
62
|
+
.join(separator.inner.clone(), ignore_nulls)
|
55
63
|
.into()
|
56
64
|
}
|
57
65
|
|
@@ -100,6 +108,10 @@ impl RbExpr {
|
|
100
108
|
.into()
|
101
109
|
}
|
102
110
|
|
111
|
+
pub fn list_tail(&self, n: &RbExpr) -> Self {
|
112
|
+
self.inner.clone().list().tail(n.inner.clone()).into()
|
113
|
+
}
|
114
|
+
|
103
115
|
pub fn list_sort(&self, reverse: bool) -> Self {
|
104
116
|
self.inner
|
105
117
|
.clone()
|
@@ -116,14 +128,50 @@ impl RbExpr {
|
|
116
128
|
self.inner.clone().list().sum().with_fmt("list.sum").into()
|
117
129
|
}
|
118
130
|
|
119
|
-
pub fn
|
131
|
+
pub fn list_drop_nulls(&self) -> Self {
|
132
|
+
self.inner.clone().list().drop_nulls().into()
|
133
|
+
}
|
134
|
+
|
135
|
+
pub fn list_sample_n(
|
136
|
+
&self,
|
137
|
+
n: &RbExpr,
|
138
|
+
with_replacement: bool,
|
139
|
+
shuffle: bool,
|
140
|
+
seed: Option<u64>,
|
141
|
+
) -> Self {
|
142
|
+
self.inner
|
143
|
+
.clone()
|
144
|
+
.list()
|
145
|
+
.sample_n(n.inner.clone(), with_replacement, shuffle, seed)
|
146
|
+
.into()
|
147
|
+
}
|
148
|
+
|
149
|
+
pub fn list_sample_fraction(
|
150
|
+
&self,
|
151
|
+
fraction: &RbExpr,
|
152
|
+
with_replacement: bool,
|
153
|
+
shuffle: bool,
|
154
|
+
seed: Option<u64>,
|
155
|
+
) -> Self {
|
156
|
+
self.inner
|
157
|
+
.clone()
|
158
|
+
.list()
|
159
|
+
.sample_fraction(fraction.inner.clone(), with_replacement, shuffle, seed)
|
160
|
+
.into()
|
161
|
+
}
|
162
|
+
|
163
|
+
pub fn list_gather(&self, index: &RbExpr, null_on_oob: bool) -> Self {
|
120
164
|
self.inner
|
121
165
|
.clone()
|
122
166
|
.list()
|
123
|
-
.
|
167
|
+
.gather(index.inner.clone(), null_on_oob)
|
124
168
|
.into()
|
125
169
|
}
|
126
170
|
|
171
|
+
pub fn list_to_array(&self, width: usize) -> Self {
|
172
|
+
self.inner.clone().list().to_array(width).into()
|
173
|
+
}
|
174
|
+
|
127
175
|
pub fn list_to_struct(
|
128
176
|
&self,
|
129
177
|
width_strat: Wrap<ListToStructWidthStrategy>,
|
data/ext/polars/src/expr/meta.rs
CHANGED
@@ -46,7 +46,55 @@ impl RbExpr {
|
|
46
46
|
self.inner.clone().meta().has_multiple_outputs()
|
47
47
|
}
|
48
48
|
|
49
|
+
pub fn meta_is_column(&self) -> bool {
|
50
|
+
self.inner.clone().meta().is_column()
|
51
|
+
}
|
52
|
+
|
49
53
|
pub fn meta_is_regex_projection(&self) -> bool {
|
50
54
|
self.inner.clone().meta().is_regex_projection()
|
51
55
|
}
|
56
|
+
|
57
|
+
pub fn _meta_selector_add(&self, other: &RbExpr) -> RbResult<RbExpr> {
|
58
|
+
let out = self
|
59
|
+
.inner
|
60
|
+
.clone()
|
61
|
+
.meta()
|
62
|
+
._selector_add(other.inner.clone())
|
63
|
+
.map_err(RbPolarsErr::from)?;
|
64
|
+
Ok(out.into())
|
65
|
+
}
|
66
|
+
|
67
|
+
pub fn _meta_selector_sub(&self, other: &RbExpr) -> RbResult<RbExpr> {
|
68
|
+
let out = self
|
69
|
+
.inner
|
70
|
+
.clone()
|
71
|
+
.meta()
|
72
|
+
._selector_sub(other.inner.clone())
|
73
|
+
.map_err(RbPolarsErr::from)?;
|
74
|
+
Ok(out.into())
|
75
|
+
}
|
76
|
+
|
77
|
+
pub fn _meta_selector_and(&self, other: &RbExpr) -> RbResult<RbExpr> {
|
78
|
+
let out = self
|
79
|
+
.inner
|
80
|
+
.clone()
|
81
|
+
.meta()
|
82
|
+
._selector_and(other.inner.clone())
|
83
|
+
.map_err(RbPolarsErr::from)?;
|
84
|
+
Ok(out.into())
|
85
|
+
}
|
86
|
+
|
87
|
+
pub fn _meta_as_selector(&self) -> RbExpr {
|
88
|
+
self.inner.clone().meta()._into_selector().into()
|
89
|
+
}
|
90
|
+
|
91
|
+
pub fn meta_tree_format(&self) -> RbResult<String> {
|
92
|
+
let e = self
|
93
|
+
.inner
|
94
|
+
.clone()
|
95
|
+
.meta()
|
96
|
+
.into_tree_formatter()
|
97
|
+
.map_err(RbPolarsErr::from)?;
|
98
|
+
Ok(format!("{e}"))
|
99
|
+
}
|
52
100
|
}
|
@@ -100,6 +100,7 @@ impl RbExpr {
|
|
100
100
|
by: Option<String>,
|
101
101
|
closed: Option<Wrap<ClosedWindow>>,
|
102
102
|
ddof: u8,
|
103
|
+
warn_if_unsorted: bool,
|
103
104
|
) -> Self {
|
104
105
|
let options = RollingOptions {
|
105
106
|
window_size: Duration::parse(&window_size),
|
@@ -109,6 +110,7 @@ impl RbExpr {
|
|
109
110
|
by,
|
110
111
|
closed_window: closed.map(|c| c.0),
|
111
112
|
fn_params: Some(Arc::new(RollingVarParams { ddof }) as Arc<dyn Any + Send + Sync>),
|
113
|
+
warn_if_unsorted,
|
112
114
|
};
|
113
115
|
|
114
116
|
self.inner.clone().rolling_std(options).into()
|
@@ -124,6 +126,7 @@ impl RbExpr {
|
|
124
126
|
by: Option<String>,
|
125
127
|
closed: Option<Wrap<ClosedWindow>>,
|
126
128
|
ddof: u8,
|
129
|
+
warn_if_unsorted: bool,
|
127
130
|
) -> Self {
|
128
131
|
let options = RollingOptions {
|
129
132
|
window_size: Duration::parse(&window_size),
|
@@ -133,11 +136,13 @@ impl RbExpr {
|
|
133
136
|
by,
|
134
137
|
closed_window: closed.map(|c| c.0),
|
135
138
|
fn_params: Some(Arc::new(RollingVarParams { ddof }) as Arc<dyn Any + Send + Sync>),
|
139
|
+
warn_if_unsorted,
|
136
140
|
};
|
137
141
|
|
138
142
|
self.inner.clone().rolling_var(options).into()
|
139
143
|
}
|
140
144
|
|
145
|
+
#[allow(clippy::too_many_arguments)]
|
141
146
|
pub fn rolling_median(
|
142
147
|
&self,
|
143
148
|
window_size: String,
|
@@ -146,6 +151,7 @@ impl RbExpr {
|
|
146
151
|
center: bool,
|
147
152
|
by: Option<String>,
|
148
153
|
closed: Option<Wrap<ClosedWindow>>,
|
154
|
+
warn_if_unsorted: bool,
|
149
155
|
) -> Self {
|
150
156
|
let options = RollingOptions {
|
151
157
|
window_size: Duration::parse(&window_size),
|
@@ -154,12 +160,10 @@ impl RbExpr {
|
|
154
160
|
center,
|
155
161
|
by,
|
156
162
|
closed_window: closed.map(|c| c.0),
|
157
|
-
fn_params:
|
158
|
-
|
159
|
-
interpol: QuantileInterpolOptions::Linear,
|
160
|
-
}) as Arc<dyn Any + Send + Sync>),
|
163
|
+
fn_params: None,
|
164
|
+
warn_if_unsorted,
|
161
165
|
};
|
162
|
-
self.inner.clone().
|
166
|
+
self.inner.clone().rolling_median(options).into()
|
163
167
|
}
|
164
168
|
|
165
169
|
#[allow(clippy::too_many_arguments)]
|
@@ -173,6 +177,7 @@ impl RbExpr {
|
|
173
177
|
center: bool,
|
174
178
|
by: Option<String>,
|
175
179
|
closed: Option<Wrap<ClosedWindow>>,
|
180
|
+
warn_if_unsorted: bool,
|
176
181
|
) -> Self {
|
177
182
|
let options = RollingOptions {
|
178
183
|
window_size: Duration::parse(&window_size),
|
@@ -181,13 +186,14 @@ impl RbExpr {
|
|
181
186
|
center,
|
182
187
|
by,
|
183
188
|
closed_window: closed.map(|c| c.0),
|
184
|
-
fn_params:
|
185
|
-
|
186
|
-
interpol: interpolation.0,
|
187
|
-
}) as Arc<dyn Any + Send + Sync>),
|
189
|
+
fn_params: None,
|
190
|
+
warn_if_unsorted,
|
188
191
|
};
|
189
192
|
|
190
|
-
self.inner
|
193
|
+
self.inner
|
194
|
+
.clone()
|
195
|
+
.rolling_quantile(interpolation.0, quantile, options)
|
196
|
+
.into()
|
191
197
|
}
|
192
198
|
|
193
199
|
pub fn rolling_skew(&self, window_size: usize, bias: bool) -> Self {
|