polars-df 0.8.0 → 0.9.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 +30 -1
- data/Cargo.lock +107 -59
- data/Cargo.toml +0 -3
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/ext/polars/Cargo.toml +15 -7
- data/ext/polars/src/batched_csv.rs +4 -4
- 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} +260 -340
- data/ext/polars/src/dataframe.rs +69 -53
- data/ext/polars/src/expr/array.rs +74 -0
- data/ext/polars/src/expr/datetime.rs +22 -56
- data/ext/polars/src/expr/general.rs +61 -33
- 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 +1 -0
- data/ext/polars/src/expr/string.rs +59 -8
- 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/string_cache.rs +14 -0
- data/ext/polars/src/{lazyframe.rs → lazyframe/mod.rs} +138 -22
- data/ext/polars/src/lib.rs +226 -168
- data/ext/polars/src/series/aggregation.rs +20 -0
- data/ext/polars/src/series/mod.rs +25 -4
- 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 +179 -43
- data/lib/polars/data_types.rb +191 -28
- data/lib/polars/date_time_expr.rb +31 -14
- data/lib/polars/exceptions.rb +12 -1
- data/lib/polars/expr.rb +866 -186
- 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 +2 -2
- data/lib/polars/io.rb +18 -25
- data/lib/polars/lazy_frame.rb +367 -53
- 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 +273 -34
- 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/testing.rb +507 -0
- data/lib/polars/utils.rb +52 -8
- data/lib/polars/version.rb +1 -1
- data/lib/polars.rb +15 -2
- metadata +35 -5
- data/lib/polars/lazy_functions.rb +0 -1181
@@ -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)
|
@@ -302,14 +312,14 @@ 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
|
|
@@ -335,7 +345,7 @@ impl RbExpr {
|
|
335
345
|
out.into()
|
336
346
|
}
|
337
347
|
|
338
|
-
pub fn fill_null(&self, expr: &
|
348
|
+
pub fn fill_null(&self, expr: &Self) -> Self {
|
339
349
|
self.clone().inner.fill_null(expr.inner.clone()).into()
|
340
350
|
}
|
341
351
|
|
@@ -356,7 +366,7 @@ impl RbExpr {
|
|
356
366
|
.into())
|
357
367
|
}
|
358
368
|
|
359
|
-
pub fn fill_nan(&self, expr: &
|
369
|
+
pub fn fill_nan(&self, expr: &Self) -> Self {
|
360
370
|
self.inner.clone().fill_nan(expr.inner.clone()).into()
|
361
371
|
}
|
362
372
|
|
@@ -368,7 +378,7 @@ impl RbExpr {
|
|
368
378
|
self.inner.clone().drop_nans().into()
|
369
379
|
}
|
370
380
|
|
371
|
-
pub fn filter(&self, predicate: &
|
381
|
+
pub fn filter(&self, predicate: &Self) -> Self {
|
372
382
|
self.clone().inner.filter(predicate.inner.clone()).into()
|
373
383
|
}
|
374
384
|
|
@@ -423,14 +433,14 @@ impl RbExpr {
|
|
423
433
|
self.clone().inner.head(n).into()
|
424
434
|
}
|
425
435
|
|
426
|
-
pub fn slice(&self, offset: &
|
436
|
+
pub fn slice(&self, offset: &Self, length: &Self) -> Self {
|
427
437
|
self.inner
|
428
438
|
.clone()
|
429
439
|
.slice(offset.inner.clone(), length.inner.clone())
|
430
440
|
.into()
|
431
441
|
}
|
432
442
|
|
433
|
-
pub fn append(&self, other: &
|
443
|
+
pub fn append(&self, other: &Self, upcast: bool) -> Self {
|
434
444
|
self.inner
|
435
445
|
.clone()
|
436
446
|
.append(other.inner.clone(), upcast)
|
@@ -532,27 +542,27 @@ impl RbExpr {
|
|
532
542
|
Ok(self.clone().inner.over(partition_by).into())
|
533
543
|
}
|
534
544
|
|
535
|
-
pub fn _and(&self, expr: &
|
545
|
+
pub fn _and(&self, expr: &Self) -> Self {
|
536
546
|
self.clone().inner.and(expr.inner.clone()).into()
|
537
547
|
}
|
538
548
|
|
539
|
-
pub fn _xor(&self, expr: &
|
549
|
+
pub fn _xor(&self, expr: &Self) -> Self {
|
540
550
|
self.clone().inner.xor(expr.inner.clone()).into()
|
541
551
|
}
|
542
552
|
|
543
|
-
pub fn _or(&self, expr: &
|
553
|
+
pub fn _or(&self, expr: &Self) -> Self {
|
544
554
|
self.clone().inner.or(expr.inner.clone()).into()
|
545
555
|
}
|
546
556
|
|
547
|
-
pub fn is_in(&self, expr: &
|
557
|
+
pub fn is_in(&self, expr: &Self) -> Self {
|
548
558
|
self.clone().inner.is_in(expr.inner.clone()).into()
|
549
559
|
}
|
550
560
|
|
551
|
-
pub fn repeat_by(&self, by: &
|
561
|
+
pub fn repeat_by(&self, by: &Self) -> Self {
|
552
562
|
self.clone().inner.repeat_by(by.inner.clone()).into()
|
553
563
|
}
|
554
564
|
|
555
|
-
pub fn pow(&self, exponent: &
|
565
|
+
pub fn pow(&self, exponent: &Self) -> Self {
|
556
566
|
self.clone().inner.pow(exponent.inner.clone()).into()
|
557
567
|
}
|
558
568
|
|
@@ -584,7 +594,7 @@ impl RbExpr {
|
|
584
594
|
map_single(self, lambda, output_type, agg_list)
|
585
595
|
}
|
586
596
|
|
587
|
-
pub fn dot(&self, other: &
|
597
|
+
pub fn dot(&self, other: &Self) -> Self {
|
588
598
|
self.inner.clone().dot(other.inner.clone()).into()
|
589
599
|
}
|
590
600
|
|
@@ -621,7 +631,7 @@ impl RbExpr {
|
|
621
631
|
self.inner.clone().upper_bound().into()
|
622
632
|
}
|
623
633
|
|
624
|
-
pub fn cumulative_eval(&self, expr: &
|
634
|
+
pub fn cumulative_eval(&self, expr: &Self, min_periods: usize, parallel: bool) -> Self {
|
625
635
|
self.inner
|
626
636
|
.clone()
|
627
637
|
.cumulative_eval(expr.inner.clone(), min_periods, parallel)
|
@@ -803,4 +813,22 @@ impl RbExpr {
|
|
803
813
|
};
|
804
814
|
self.inner.clone().set_sorted_flag(is_sorted).into()
|
805
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
|
+
}
|
806
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
|
}
|
@@ -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 {
|
@@ -245,7 +253,7 @@ impl RbExpr {
|
|
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
|
}
|
@@ -33,3 +33,9 @@ pub fn sum_horizontal(exprs: RArray) -> RbResult<RbExpr> {
|
|
33
33
|
let e = dsl::sum_horizontal(exprs).map_err(RbPolarsErr::from)?;
|
34
34
|
Ok(e.into())
|
35
35
|
}
|
36
|
+
|
37
|
+
pub fn mean_horizontal(exprs: RArray) -> RbResult<RbExpr> {
|
38
|
+
let exprs = rb_exprs_to_exprs(exprs)?;
|
39
|
+
let e = dsl::mean_horizontal(exprs).map_err(RbPolarsErr::from)?;
|
40
|
+
Ok(e.into())
|
41
|
+
}
|