polars-df 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -1
- data/Cargo.lock +159 -66
- data/Cargo.toml +0 -3
- data/LICENSE.txt +1 -1
- data/README.md +3 -2
- data/ext/polars/Cargo.toml +18 -8
- data/ext/polars/src/batched_csv.rs +7 -5
- data/ext/polars/src/conversion/anyvalue.rs +186 -0
- data/ext/polars/src/conversion/chunked_array.rs +140 -0
- data/ext/polars/src/{conversion.rs → conversion/mod.rs} +273 -342
- data/ext/polars/src/dataframe.rs +108 -66
- data/ext/polars/src/expr/array.rs +78 -0
- data/ext/polars/src/expr/datetime.rs +29 -58
- data/ext/polars/src/expr/general.rs +83 -36
- data/ext/polars/src/expr/list.rs +58 -6
- data/ext/polars/src/expr/meta.rs +48 -0
- data/ext/polars/src/expr/rolling.rs +1 -0
- data/ext/polars/src/expr/string.rs +62 -11
- data/ext/polars/src/expr/struct.rs +8 -4
- data/ext/polars/src/file.rs +158 -11
- data/ext/polars/src/functions/aggregation.rs +6 -0
- data/ext/polars/src/functions/lazy.rs +120 -50
- data/ext/polars/src/functions/meta.rs +45 -1
- data/ext/polars/src/functions/string_cache.rs +14 -0
- data/ext/polars/src/functions/whenthen.rs +47 -17
- data/ext/polars/src/{lazyframe.rs → lazyframe/mod.rs} +195 -40
- data/ext/polars/src/lib.rs +246 -179
- data/ext/polars/src/map/dataframe.rs +17 -9
- data/ext/polars/src/series/aggregation.rs +20 -0
- data/ext/polars/src/series/mod.rs +35 -4
- data/lib/polars/array_expr.rb +453 -0
- data/lib/polars/array_name_space.rb +346 -0
- data/lib/polars/batched_csv_reader.rb +4 -2
- 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 +306 -96
- data/lib/polars/data_types.rb +191 -28
- data/lib/polars/date_time_expr.rb +41 -18
- data/lib/polars/date_time_name_space.rb +9 -3
- data/lib/polars/exceptions.rb +12 -1
- data/lib/polars/expr.rb +898 -215
- 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 +96 -0
- data/lib/polars/functions.rb +29 -416
- data/lib/polars/group_by.rb +2 -2
- data/lib/polars/io.rb +36 -31
- data/lib/polars/lazy_frame.rb +405 -88
- data/lib/polars/list_expr.rb +158 -8
- data/lib/polars/list_name_space.rb +102 -0
- data/lib/polars/meta_expr.rb +175 -7
- data/lib/polars/series.rb +282 -41
- data/lib/polars/string_cache.rb +75 -0
- data/lib/polars/string_expr.rb +413 -96
- data/lib/polars/string_name_space.rb +4 -4
- data/lib/polars/testing.rb +507 -0
- data/lib/polars/utils.rb +106 -8
- data/lib/polars/version.rb +1 -1
- data/lib/polars/whenthen.rb +83 -0
- data/lib/polars.rb +16 -4
- metadata +37 -8
- data/lib/polars/lazy_functions.rb +0 -1181
- data/lib/polars/when.rb +0 -16
- data/lib/polars/when_then.rb +0 -19
@@ -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,11 +165,7 @@ 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)
|
@@ -257,7 +267,7 @@ impl RbExpr {
|
|
257
267
|
pub fn sort_with(&self, descending: bool, nulls_last: bool) -> Self {
|
258
268
|
self.clone()
|
259
269
|
.inner
|
260
|
-
.
|
270
|
+
.sort(SortOptions {
|
261
271
|
descending,
|
262
272
|
nulls_last,
|
263
273
|
multithreaded: true,
|
@@ -302,20 +312,39 @@ impl RbExpr {
|
|
302
312
|
self.clone().inner.arg_min().into()
|
303
313
|
}
|
304
314
|
|
305
|
-
pub fn search_sorted(&self, element: &
|
315
|
+
pub fn search_sorted(&self, element: &Self, side: Wrap<SearchSortedSide>) -> Self {
|
306
316
|
self.inner
|
307
317
|
.clone()
|
308
318
|
.search_sorted(element.inner.clone(), side.0)
|
309
319
|
.into()
|
310
320
|
}
|
311
321
|
|
312
|
-
pub fn gather(&self, idx: &
|
322
|
+
pub fn gather(&self, idx: &Self) -> Self {
|
313
323
|
self.clone().inner.gather(idx.inner.clone()).into()
|
314
324
|
}
|
315
325
|
|
316
|
-
pub fn sort_by(
|
326
|
+
pub fn sort_by(
|
327
|
+
&self,
|
328
|
+
by: RArray,
|
329
|
+
descending: Vec<bool>,
|
330
|
+
nulls_last: bool,
|
331
|
+
multithreaded: bool,
|
332
|
+
maintain_order: bool,
|
333
|
+
) -> RbResult<Self> {
|
317
334
|
let by = rb_exprs_to_exprs(by)?;
|
318
|
-
Ok(self
|
335
|
+
Ok(self
|
336
|
+
.clone()
|
337
|
+
.inner
|
338
|
+
.sort_by(
|
339
|
+
by,
|
340
|
+
SortMultipleOptions {
|
341
|
+
descending,
|
342
|
+
nulls_last,
|
343
|
+
multithreaded,
|
344
|
+
maintain_order,
|
345
|
+
},
|
346
|
+
)
|
347
|
+
.into())
|
319
348
|
}
|
320
349
|
|
321
350
|
pub fn backward_fill(&self, limit: FillNullLimit) -> Self {
|
@@ -335,7 +364,7 @@ impl RbExpr {
|
|
335
364
|
out.into()
|
336
365
|
}
|
337
366
|
|
338
|
-
pub fn fill_null(&self, expr: &
|
367
|
+
pub fn fill_null(&self, expr: &Self) -> Self {
|
339
368
|
self.clone().inner.fill_null(expr.inner.clone()).into()
|
340
369
|
}
|
341
370
|
|
@@ -356,7 +385,7 @@ impl RbExpr {
|
|
356
385
|
.into())
|
357
386
|
}
|
358
387
|
|
359
|
-
pub fn fill_nan(&self, expr: &
|
388
|
+
pub fn fill_nan(&self, expr: &Self) -> Self {
|
360
389
|
self.inner.clone().fill_nan(expr.inner.clone()).into()
|
361
390
|
}
|
362
391
|
|
@@ -368,7 +397,7 @@ impl RbExpr {
|
|
368
397
|
self.inner.clone().drop_nans().into()
|
369
398
|
}
|
370
399
|
|
371
|
-
pub fn filter(&self, predicate: &
|
400
|
+
pub fn filter(&self, predicate: &Self) -> Self {
|
372
401
|
self.clone().inner.filter(predicate.inner.clone()).into()
|
373
402
|
}
|
374
403
|
|
@@ -423,14 +452,14 @@ impl RbExpr {
|
|
423
452
|
self.clone().inner.head(n).into()
|
424
453
|
}
|
425
454
|
|
426
|
-
pub fn slice(&self, offset: &
|
455
|
+
pub fn slice(&self, offset: &Self, length: &Self) -> Self {
|
427
456
|
self.inner
|
428
457
|
.clone()
|
429
458
|
.slice(offset.inner.clone(), length.inner.clone())
|
430
459
|
.into()
|
431
460
|
}
|
432
461
|
|
433
|
-
pub fn append(&self, other: &
|
462
|
+
pub fn append(&self, other: &Self, upcast: bool) -> Self {
|
434
463
|
self.inner
|
435
464
|
.clone()
|
436
465
|
.append(other.inner.clone(), upcast)
|
@@ -532,27 +561,27 @@ impl RbExpr {
|
|
532
561
|
Ok(self.clone().inner.over(partition_by).into())
|
533
562
|
}
|
534
563
|
|
535
|
-
pub fn _and(&self, expr: &
|
564
|
+
pub fn _and(&self, expr: &Self) -> Self {
|
536
565
|
self.clone().inner.and(expr.inner.clone()).into()
|
537
566
|
}
|
538
567
|
|
539
|
-
pub fn _xor(&self, expr: &
|
568
|
+
pub fn _xor(&self, expr: &Self) -> Self {
|
540
569
|
self.clone().inner.xor(expr.inner.clone()).into()
|
541
570
|
}
|
542
571
|
|
543
|
-
pub fn _or(&self, expr: &
|
572
|
+
pub fn _or(&self, expr: &Self) -> Self {
|
544
573
|
self.clone().inner.or(expr.inner.clone()).into()
|
545
574
|
}
|
546
575
|
|
547
|
-
pub fn is_in(&self, expr: &
|
576
|
+
pub fn is_in(&self, expr: &Self) -> Self {
|
548
577
|
self.clone().inner.is_in(expr.inner.clone()).into()
|
549
578
|
}
|
550
579
|
|
551
|
-
pub fn repeat_by(&self, by: &
|
580
|
+
pub fn repeat_by(&self, by: &Self) -> Self {
|
552
581
|
self.clone().inner.repeat_by(by.inner.clone()).into()
|
553
582
|
}
|
554
583
|
|
555
|
-
pub fn pow(&self, exponent: &
|
584
|
+
pub fn pow(&self, exponent: &Self) -> Self {
|
556
585
|
self.clone().inner.pow(exponent.inner.clone()).into()
|
557
586
|
}
|
558
587
|
|
@@ -584,7 +613,7 @@ impl RbExpr {
|
|
584
613
|
map_single(self, lambda, output_type, agg_list)
|
585
614
|
}
|
586
615
|
|
587
|
-
pub fn dot(&self, other: &
|
616
|
+
pub fn dot(&self, other: &Self) -> Self {
|
588
617
|
self.inner.clone().dot(other.inner.clone()).into()
|
589
618
|
}
|
590
619
|
|
@@ -621,7 +650,7 @@ impl RbExpr {
|
|
621
650
|
self.inner.clone().upper_bound().into()
|
622
651
|
}
|
623
652
|
|
624
|
-
pub fn cumulative_eval(&self, expr: &
|
653
|
+
pub fn cumulative_eval(&self, expr: &Self, min_periods: usize, parallel: bool) -> Self {
|
625
654
|
self.inner
|
626
655
|
.clone()
|
627
656
|
.cumulative_eval(expr.inner.clone(), min_periods, parallel)
|
@@ -803,4 +832,22 @@ impl RbExpr {
|
|
803
832
|
};
|
804
833
|
self.inner.clone().set_sorted_flag(is_sorted).into()
|
805
834
|
}
|
835
|
+
|
836
|
+
pub fn replace(
|
837
|
+
&self,
|
838
|
+
old: &Self,
|
839
|
+
new: &Self,
|
840
|
+
default: Option<&Self>,
|
841
|
+
return_dtype: Option<Wrap<DataType>>,
|
842
|
+
) -> Self {
|
843
|
+
self.inner
|
844
|
+
.clone()
|
845
|
+
.replace(
|
846
|
+
old.inner.clone(),
|
847
|
+
new.inner.clone(),
|
848
|
+
default.map(|e| e.inner.clone()),
|
849
|
+
return_dtype.map(|dt| dt.0),
|
850
|
+
)
|
851
|
+
.into()
|
852
|
+
}
|
806
853
|
}
|
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
|
}
|
@@ -43,15 +51,19 @@ impl RbExpr {
|
|
43
51
|
.into()
|
44
52
|
}
|
45
53
|
|
46
|
-
pub fn list_get(&self, index: &RbExpr) -> Self {
|
47
|
-
self.inner
|
54
|
+
pub fn list_get(&self, index: &RbExpr, null_on_oob: bool) -> Self {
|
55
|
+
self.inner
|
56
|
+
.clone()
|
57
|
+
.list()
|
58
|
+
.get(index.inner.clone(), null_on_oob)
|
59
|
+
.into()
|
48
60
|
}
|
49
61
|
|
50
|
-
pub fn list_join(&self, separator: &RbExpr) -> Self {
|
62
|
+
pub fn list_join(&self, separator: &RbExpr, ignore_nulls: bool) -> Self {
|
51
63
|
self.inner
|
52
64
|
.clone()
|
53
65
|
.list()
|
54
|
-
.join(separator.inner.clone())
|
66
|
+
.join(separator.inner.clone(), ignore_nulls)
|
55
67
|
.into()
|
56
68
|
}
|
57
69
|
|
@@ -100,6 +112,10 @@ impl RbExpr {
|
|
100
112
|
.into()
|
101
113
|
}
|
102
114
|
|
115
|
+
pub fn list_tail(&self, n: &RbExpr) -> Self {
|
116
|
+
self.inner.clone().list().tail(n.inner.clone()).into()
|
117
|
+
}
|
118
|
+
|
103
119
|
pub fn list_sort(&self, reverse: bool) -> Self {
|
104
120
|
self.inner
|
105
121
|
.clone()
|
@@ -116,14 +132,50 @@ impl RbExpr {
|
|
116
132
|
self.inner.clone().list().sum().with_fmt("list.sum").into()
|
117
133
|
}
|
118
134
|
|
119
|
-
pub fn
|
135
|
+
pub fn list_drop_nulls(&self) -> Self {
|
136
|
+
self.inner.clone().list().drop_nulls().into()
|
137
|
+
}
|
138
|
+
|
139
|
+
pub fn list_sample_n(
|
140
|
+
&self,
|
141
|
+
n: &RbExpr,
|
142
|
+
with_replacement: bool,
|
143
|
+
shuffle: bool,
|
144
|
+
seed: Option<u64>,
|
145
|
+
) -> Self {
|
146
|
+
self.inner
|
147
|
+
.clone()
|
148
|
+
.list()
|
149
|
+
.sample_n(n.inner.clone(), with_replacement, shuffle, seed)
|
150
|
+
.into()
|
151
|
+
}
|
152
|
+
|
153
|
+
pub fn list_sample_fraction(
|
154
|
+
&self,
|
155
|
+
fraction: &RbExpr,
|
156
|
+
with_replacement: bool,
|
157
|
+
shuffle: bool,
|
158
|
+
seed: Option<u64>,
|
159
|
+
) -> Self {
|
160
|
+
self.inner
|
161
|
+
.clone()
|
162
|
+
.list()
|
163
|
+
.sample_fraction(fraction.inner.clone(), with_replacement, shuffle, seed)
|
164
|
+
.into()
|
165
|
+
}
|
166
|
+
|
167
|
+
pub fn list_gather(&self, index: &RbExpr, null_on_oob: bool) -> Self {
|
120
168
|
self.inner
|
121
169
|
.clone()
|
122
170
|
.list()
|
123
|
-
.
|
171
|
+
.gather(index.inner.clone(), null_on_oob)
|
124
172
|
.into()
|
125
173
|
}
|
126
174
|
|
175
|
+
pub fn list_to_array(&self, width: usize) -> Self {
|
176
|
+
self.inner.clone().list().to_array(width).into()
|
177
|
+
}
|
178
|
+
|
127
179
|
pub fn list_to_struct(
|
128
180
|
&self,
|
129
181
|
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
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
use polars::prelude::*;
|
2
2
|
|
3
3
|
use crate::conversion::Wrap;
|
4
|
-
use crate::RbExpr;
|
4
|
+
use crate::{RbExpr, RbPolarsErr, RbResult};
|
5
5
|
|
6
6
|
impl RbExpr {
|
7
7
|
pub fn str_concat(&self, delimiter: String, ignore_nulls: bool) -> Self {
|
@@ -107,8 +107,12 @@ impl RbExpr {
|
|
107
107
|
.into()
|
108
108
|
}
|
109
109
|
|
110
|
-
pub fn str_slice(&self, start:
|
111
|
-
self.inner
|
110
|
+
pub fn str_slice(&self, start: &Self, length: &Self) -> Self {
|
111
|
+
self.inner
|
112
|
+
.clone()
|
113
|
+
.str()
|
114
|
+
.slice(start.inner.clone(), length.inner.clone())
|
115
|
+
.into()
|
112
116
|
}
|
113
117
|
|
114
118
|
pub fn str_explode(&self) -> Self {
|
@@ -147,6 +151,10 @@ impl RbExpr {
|
|
147
151
|
.into()
|
148
152
|
}
|
149
153
|
|
154
|
+
pub fn str_reverse(&self) -> Self {
|
155
|
+
self.inner.clone().str().reverse().into()
|
156
|
+
}
|
157
|
+
|
150
158
|
pub fn str_pad_start(&self, length: usize, fillchar: char) -> Self {
|
151
159
|
self.clone().inner.str().pad_start(length, fillchar).into()
|
152
160
|
}
|
@@ -155,8 +163,8 @@ impl RbExpr {
|
|
155
163
|
self.clone().inner.str().pad_end(length, fillchar).into()
|
156
164
|
}
|
157
165
|
|
158
|
-
pub fn str_zfill(&self,
|
159
|
-
self.clone().inner.str().zfill(
|
166
|
+
pub fn str_zfill(&self, length: &Self) -> Self {
|
167
|
+
self.clone().inner.str().zfill(length.inner.clone()).into()
|
160
168
|
}
|
161
169
|
|
162
170
|
pub fn str_contains(&self, pat: &RbExpr, literal: Option<bool>, strict: bool) -> Self {
|
@@ -236,16 +244,16 @@ impl RbExpr {
|
|
236
244
|
.into()
|
237
245
|
}
|
238
246
|
|
239
|
-
pub fn str_to_integer(&self, base:
|
247
|
+
pub fn str_to_integer(&self, base: &Self, strict: bool) -> Self {
|
240
248
|
self.inner
|
241
249
|
.clone()
|
242
250
|
.str()
|
243
|
-
.to_integer(base, strict)
|
244
|
-
.with_fmt("str.
|
251
|
+
.to_integer(base.inner.clone(), strict)
|
252
|
+
.with_fmt("str.to_integer")
|
245
253
|
.into()
|
246
254
|
}
|
247
255
|
|
248
|
-
pub fn
|
256
|
+
pub fn str_json_decode(
|
249
257
|
&self,
|
250
258
|
dtype: Option<Wrap<DataType>>,
|
251
259
|
infer_schema_len: Option<usize>,
|
@@ -287,8 +295,12 @@ impl RbExpr {
|
|
287
295
|
.into()
|
288
296
|
}
|
289
297
|
|
290
|
-
pub fn str_extract(&self, pat:
|
291
|
-
self.inner
|
298
|
+
pub fn str_extract(&self, pat: &Self, group_index: usize) -> Self {
|
299
|
+
self.inner
|
300
|
+
.clone()
|
301
|
+
.str()
|
302
|
+
.extract(pat.inner.clone(), group_index)
|
303
|
+
.into()
|
292
304
|
}
|
293
305
|
|
294
306
|
pub fn str_extract_all(&self, pat: &RbExpr) -> Self {
|
@@ -299,6 +311,16 @@ impl RbExpr {
|
|
299
311
|
.into()
|
300
312
|
}
|
301
313
|
|
314
|
+
pub fn str_extract_groups(&self, pat: String) -> RbResult<Self> {
|
315
|
+
Ok(self
|
316
|
+
.inner
|
317
|
+
.clone()
|
318
|
+
.str()
|
319
|
+
.extract_groups(&pat)
|
320
|
+
.map_err(RbPolarsErr::from)?
|
321
|
+
.into())
|
322
|
+
}
|
323
|
+
|
302
324
|
pub fn str_count_matches(&self, pat: &Self, literal: bool) -> Self {
|
303
325
|
self.inner
|
304
326
|
.clone()
|
@@ -338,4 +360,33 @@ impl RbExpr {
|
|
338
360
|
pub fn str_splitn(&self, by: &Self, n: usize) -> Self {
|
339
361
|
self.inner.clone().str().splitn(by.inner.clone(), n).into()
|
340
362
|
}
|
363
|
+
|
364
|
+
pub fn str_to_decimal(&self, infer_len: usize) -> Self {
|
365
|
+
self.inner.clone().str().to_decimal(infer_len).into()
|
366
|
+
}
|
367
|
+
|
368
|
+
pub fn str_contains_any(&self, patterns: &RbExpr, ascii_case_insensitive: bool) -> Self {
|
369
|
+
self.inner
|
370
|
+
.clone()
|
371
|
+
.str()
|
372
|
+
.contains_any(patterns.inner.clone(), ascii_case_insensitive)
|
373
|
+
.into()
|
374
|
+
}
|
375
|
+
|
376
|
+
pub fn str_replace_many(
|
377
|
+
&self,
|
378
|
+
patterns: &RbExpr,
|
379
|
+
replace_with: &RbExpr,
|
380
|
+
ascii_case_insensitive: bool,
|
381
|
+
) -> Self {
|
382
|
+
self.inner
|
383
|
+
.clone()
|
384
|
+
.str()
|
385
|
+
.replace_many(
|
386
|
+
patterns.inner.clone(),
|
387
|
+
replace_with.inner.clone(),
|
388
|
+
ascii_case_insensitive,
|
389
|
+
)
|
390
|
+
.into()
|
391
|
+
}
|
341
392
|
}
|
@@ -1,15 +1,19 @@
|
|
1
1
|
use crate::RbExpr;
|
2
2
|
|
3
3
|
impl RbExpr {
|
4
|
-
pub fn struct_field_by_name(&self, name: String) -> Self {
|
5
|
-
self.inner.clone().struct_().field_by_name(&name).into()
|
6
|
-
}
|
7
|
-
|
8
4
|
pub fn struct_field_by_index(&self, index: i64) -> Self {
|
9
5
|
self.inner.clone().struct_().field_by_index(index).into()
|
10
6
|
}
|
11
7
|
|
8
|
+
pub fn struct_field_by_name(&self, name: String) -> Self {
|
9
|
+
self.inner.clone().struct_().field_by_name(&name).into()
|
10
|
+
}
|
11
|
+
|
12
12
|
pub fn struct_rename_fields(&self, names: Vec<String>) -> Self {
|
13
13
|
self.inner.clone().struct_().rename_fields(names).into()
|
14
14
|
}
|
15
|
+
|
16
|
+
pub fn struct_json_encode(&self) -> Self {
|
17
|
+
self.inner.clone().struct_().json_encode().into()
|
18
|
+
}
|
15
19
|
}
|