polars-df 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/Cargo.lock +360 -361
  4. data/ext/polars/Cargo.toml +10 -7
  5. data/ext/polars/src/batched_csv.rs +1 -1
  6. data/ext/polars/src/conversion/any_value.rs +261 -0
  7. data/ext/polars/src/conversion/chunked_array.rs +4 -4
  8. data/ext/polars/src/conversion/mod.rs +51 -10
  9. data/ext/polars/src/dataframe/construction.rs +6 -8
  10. data/ext/polars/src/dataframe/general.rs +19 -29
  11. data/ext/polars/src/dataframe/io.rs +43 -33
  12. data/ext/polars/src/error.rs +26 -4
  13. data/ext/polars/src/expr/categorical.rs +0 -10
  14. data/ext/polars/src/expr/datetime.rs +4 -12
  15. data/ext/polars/src/expr/general.rs +123 -110
  16. data/ext/polars/src/expr/mod.rs +2 -2
  17. data/ext/polars/src/expr/rolling.rs +17 -9
  18. data/ext/polars/src/expr/string.rs +2 -6
  19. data/ext/polars/src/functions/eager.rs +10 -10
  20. data/ext/polars/src/functions/lazy.rs +21 -21
  21. data/ext/polars/src/functions/range.rs +6 -12
  22. data/ext/polars/src/interop/numo/to_numo_series.rs +2 -1
  23. data/ext/polars/src/lazyframe/mod.rs +81 -98
  24. data/ext/polars/src/lib.rs +55 -45
  25. data/ext/polars/src/map/dataframe.rs +2 -2
  26. data/ext/polars/src/rb_modules.rs +25 -1
  27. data/ext/polars/src/series/aggregation.rs +4 -2
  28. data/ext/polars/src/series/arithmetic.rs +21 -11
  29. data/ext/polars/src/series/construction.rs +56 -38
  30. data/ext/polars/src/series/export.rs +1 -1
  31. data/ext/polars/src/series/mod.rs +31 -10
  32. data/ext/polars/src/sql.rs +3 -1
  33. data/lib/polars/array_expr.rb +4 -4
  34. data/lib/polars/batched_csv_reader.rb +2 -2
  35. data/lib/polars/cat_expr.rb +0 -36
  36. data/lib/polars/cat_name_space.rb +0 -37
  37. data/lib/polars/data_frame.rb +93 -101
  38. data/lib/polars/data_types.rb +1 -1
  39. data/lib/polars/date_time_expr.rb +525 -573
  40. data/lib/polars/date_time_name_space.rb +263 -464
  41. data/lib/polars/dynamic_group_by.rb +3 -3
  42. data/lib/polars/exceptions.rb +3 -0
  43. data/lib/polars/expr.rb +367 -330
  44. data/lib/polars/expr_dispatch.rb +1 -1
  45. data/lib/polars/functions/aggregation/horizontal.rb +8 -8
  46. data/lib/polars/functions/as_datatype.rb +63 -40
  47. data/lib/polars/functions/lazy.rb +63 -14
  48. data/lib/polars/functions/lit.rb +1 -1
  49. data/lib/polars/functions/range/date_range.rb +18 -77
  50. data/lib/polars/functions/range/datetime_range.rb +4 -4
  51. data/lib/polars/functions/range/int_range.rb +2 -2
  52. data/lib/polars/functions/range/time_range.rb +4 -4
  53. data/lib/polars/functions/repeat.rb +1 -1
  54. data/lib/polars/functions/whenthen.rb +1 -1
  55. data/lib/polars/io/csv.rb +8 -8
  56. data/lib/polars/io/ipc.rb +3 -3
  57. data/lib/polars/io/json.rb +13 -2
  58. data/lib/polars/io/ndjson.rb +15 -4
  59. data/lib/polars/io/parquet.rb +5 -4
  60. data/lib/polars/lazy_frame.rb +120 -106
  61. data/lib/polars/lazy_group_by.rb +1 -1
  62. data/lib/polars/list_expr.rb +11 -11
  63. data/lib/polars/list_name_space.rb +5 -1
  64. data/lib/polars/rolling_group_by.rb +5 -7
  65. data/lib/polars/series.rb +105 -189
  66. data/lib/polars/string_expr.rb +42 -67
  67. data/lib/polars/string_name_space.rb +5 -4
  68. data/lib/polars/testing.rb +2 -2
  69. data/lib/polars/utils/constants.rb +9 -0
  70. data/lib/polars/utils/convert.rb +97 -0
  71. data/lib/polars/utils/parse.rb +89 -0
  72. data/lib/polars/utils/various.rb +76 -0
  73. data/lib/polars/utils/wrap.rb +19 -0
  74. data/lib/polars/utils.rb +4 -330
  75. data/lib/polars/version.rb +1 -1
  76. data/lib/polars/whenthen.rb +6 -6
  77. data/lib/polars.rb +11 -0
  78. metadata +9 -4
  79. data/ext/polars/src/conversion/anyvalue.rs +0 -186
@@ -46,7 +46,7 @@ impl RbExpr {
46
46
  }
47
47
 
48
48
  pub fn eq(&self, other: &Self) -> Self {
49
- self.clone().inner.eq(other.inner.clone()).into()
49
+ self.inner.clone().eq(other.inner.clone()).into()
50
50
  }
51
51
 
52
52
  pub fn eq_missing(&self, other: &Self) -> Self {
@@ -54,7 +54,7 @@ impl RbExpr {
54
54
  }
55
55
 
56
56
  pub fn neq(&self, other: &Self) -> Self {
57
- self.clone().inner.neq(other.inner.clone()).into()
57
+ self.inner.clone().neq(other.inner.clone()).into()
58
58
  }
59
59
 
60
60
  pub fn neq_missing(&self, other: &Self) -> Self {
@@ -62,112 +62,112 @@ impl RbExpr {
62
62
  }
63
63
 
64
64
  pub fn gt(&self, other: &Self) -> Self {
65
- self.clone().inner.gt(other.inner.clone()).into()
65
+ self.inner.clone().gt(other.inner.clone()).into()
66
66
  }
67
67
 
68
68
  pub fn gt_eq(&self, other: &Self) -> Self {
69
- self.clone().inner.gt_eq(other.inner.clone()).into()
69
+ self.inner.clone().gt_eq(other.inner.clone()).into()
70
70
  }
71
71
 
72
72
  pub fn lt_eq(&self, other: &Self) -> Self {
73
- self.clone().inner.lt_eq(other.inner.clone()).into()
73
+ self.inner.clone().lt_eq(other.inner.clone()).into()
74
74
  }
75
75
 
76
76
  pub fn lt(&self, other: &Self) -> Self {
77
- self.clone().inner.lt(other.inner.clone()).into()
77
+ self.inner.clone().lt(other.inner.clone()).into()
78
78
  }
79
79
 
80
80
  pub fn alias(&self, name: String) -> Self {
81
- self.clone().inner.alias(&name).into()
81
+ self.inner.clone().alias(&name).into()
82
82
  }
83
83
 
84
84
  pub fn not_(&self) -> Self {
85
- self.clone().inner.not().into()
85
+ self.inner.clone().not().into()
86
86
  }
87
87
 
88
88
  pub fn is_null(&self) -> Self {
89
- self.clone().inner.is_null().into()
89
+ self.inner.clone().is_null().into()
90
90
  }
91
91
 
92
92
  pub fn is_not_null(&self) -> Self {
93
- self.clone().inner.is_not_null().into()
93
+ self.inner.clone().is_not_null().into()
94
94
  }
95
95
 
96
96
  pub fn is_infinite(&self) -> Self {
97
- self.clone().inner.is_infinite().into()
97
+ self.inner.clone().is_infinite().into()
98
98
  }
99
99
 
100
100
  pub fn is_finite(&self) -> Self {
101
- self.clone().inner.is_finite().into()
101
+ self.inner.clone().is_finite().into()
102
102
  }
103
103
 
104
104
  pub fn is_nan(&self) -> Self {
105
- self.clone().inner.is_nan().into()
105
+ self.inner.clone().is_nan().into()
106
106
  }
107
107
 
108
108
  pub fn is_not_nan(&self) -> Self {
109
- self.clone().inner.is_not_nan().into()
109
+ self.inner.clone().is_not_nan().into()
110
110
  }
111
111
 
112
112
  pub fn min(&self) -> Self {
113
- self.clone().inner.min().into()
113
+ self.inner.clone().min().into()
114
114
  }
115
115
 
116
116
  pub fn max(&self) -> Self {
117
- self.clone().inner.max().into()
117
+ self.inner.clone().max().into()
118
118
  }
119
119
 
120
120
  pub fn nan_max(&self) -> Self {
121
- self.clone().inner.nan_max().into()
121
+ self.inner.clone().nan_max().into()
122
122
  }
123
123
 
124
124
  pub fn nan_min(&self) -> Self {
125
- self.clone().inner.nan_min().into()
125
+ self.inner.clone().nan_min().into()
126
126
  }
127
127
 
128
128
  pub fn mean(&self) -> Self {
129
- self.clone().inner.mean().into()
129
+ self.inner.clone().mean().into()
130
130
  }
131
131
 
132
132
  pub fn median(&self) -> Self {
133
- self.clone().inner.median().into()
133
+ self.inner.clone().median().into()
134
134
  }
135
135
 
136
136
  pub fn sum(&self) -> Self {
137
- self.clone().inner.sum().into()
137
+ self.inner.clone().sum().into()
138
138
  }
139
139
 
140
140
  pub fn n_unique(&self) -> Self {
141
- self.clone().inner.n_unique().into()
141
+ self.inner.clone().n_unique().into()
142
142
  }
143
143
 
144
144
  pub fn arg_unique(&self) -> Self {
145
- self.clone().inner.arg_unique().into()
145
+ self.inner.clone().arg_unique().into()
146
146
  }
147
147
 
148
148
  pub fn unique(&self) -> Self {
149
- self.clone().inner.unique().into()
149
+ self.inner.clone().unique().into()
150
150
  }
151
151
 
152
152
  pub fn unique_stable(&self) -> Self {
153
- self.clone().inner.unique_stable().into()
153
+ self.inner.clone().unique_stable().into()
154
154
  }
155
155
 
156
156
  pub fn first(&self) -> Self {
157
- self.clone().inner.first().into()
157
+ self.inner.clone().first().into()
158
158
  }
159
159
 
160
160
  pub fn last(&self) -> Self {
161
- self.clone().inner.last().into()
161
+ self.inner.clone().last().into()
162
162
  }
163
163
 
164
164
  pub fn implode(&self) -> Self {
165
- self.clone().inner.implode().into()
165
+ self.inner.clone().implode().into()
166
166
  }
167
167
 
168
168
  pub fn quantile(&self, quantile: &Self, interpolation: Wrap<QuantileInterpolOptions>) -> Self {
169
- self.clone()
170
- .inner
169
+ self.inner
170
+ .clone()
171
171
  .quantile(quantile.inner.clone(), interpolation.0)
172
172
  .into()
173
173
  }
@@ -239,10 +239,10 @@ impl RbExpr {
239
239
  self.inner.clone().len().into()
240
240
  }
241
241
 
242
- pub fn value_counts(&self, multithreaded: bool, sorted: bool) -> Self {
242
+ pub fn value_counts(&self, sort: bool, parallel: bool, name: String, normalize: bool) -> Self {
243
243
  self.inner
244
244
  .clone()
245
- .value_counts(multithreaded, sorted)
245
+ .value_counts(sort, parallel, name, normalize)
246
246
  .into()
247
247
  }
248
248
 
@@ -288,28 +288,30 @@ impl RbExpr {
288
288
  .into()
289
289
  }
290
290
 
291
- pub fn top_k(&self, k: &Self, nulls_last: bool, multithreaded: bool) -> Self {
292
- self.inner
291
+ pub fn top_k(&self, k: &Self) -> Self {
292
+ self.inner.clone().top_k(k.inner.clone()).into()
293
+ }
294
+
295
+ pub fn top_k_by(&self, by: RArray, k: &Self, reverse: Vec<bool>) -> RbResult<Self> {
296
+ let by = rb_exprs_to_exprs(by)?;
297
+ Ok(self
298
+ .inner
293
299
  .clone()
294
- .top_k(
295
- k.inner.clone(),
296
- SortOptions::default()
297
- .with_nulls_last(nulls_last)
298
- .with_maintain_order(multithreaded),
299
- )
300
- .into()
300
+ .top_k_by(k.inner.clone(), by, reverse)
301
+ .into())
301
302
  }
302
303
 
303
- pub fn bottom_k(&self, k: &Self, nulls_last: bool, multithreaded: bool) -> Self {
304
- self.inner
304
+ pub fn bottom_k(&self, k: &Self) -> Self {
305
+ self.inner.clone().bottom_k(k.inner.clone()).into()
306
+ }
307
+
308
+ pub fn bottom_k_by(&self, by: RArray, k: &Self, reverse: Vec<bool>) -> RbResult<Self> {
309
+ let by = rb_exprs_to_exprs(by)?;
310
+ Ok(self
311
+ .inner
305
312
  .clone()
306
- .bottom_k(
307
- k.inner.clone(),
308
- SortOptions::default()
309
- .with_nulls_last(nulls_last)
310
- .with_maintain_order(multithreaded),
311
- )
312
- .into()
313
+ .bottom_k_by(k.inner.clone(), by, reverse)
314
+ .into())
313
315
  }
314
316
 
315
317
  pub fn peak_min(&self) -> Self {
@@ -321,11 +323,11 @@ impl RbExpr {
321
323
  }
322
324
 
323
325
  pub fn arg_max(&self) -> Self {
324
- self.clone().inner.arg_max().into()
326
+ self.inner.clone().arg_max().into()
325
327
  }
326
328
 
327
329
  pub fn arg_min(&self) -> Self {
328
- self.clone().inner.arg_min().into()
330
+ self.inner.clone().arg_min().into()
329
331
  }
330
332
 
331
333
  pub fn search_sorted(&self, element: &Self, side: Wrap<SearchSortedSide>) -> Self {
@@ -336,21 +338,25 @@ impl RbExpr {
336
338
  }
337
339
 
338
340
  pub fn gather(&self, idx: &Self) -> Self {
339
- self.clone().inner.gather(idx.inner.clone()).into()
341
+ self.inner.clone().gather(idx.inner.clone()).into()
342
+ }
343
+
344
+ pub fn get(&self, idx: &Self) -> Self {
345
+ self.inner.clone().get(idx.inner.clone()).into()
340
346
  }
341
347
 
342
348
  pub fn sort_by(
343
349
  &self,
344
350
  by: RArray,
345
351
  descending: Vec<bool>,
346
- nulls_last: bool,
352
+ nulls_last: Vec<bool>,
347
353
  multithreaded: bool,
348
354
  maintain_order: bool,
349
355
  ) -> RbResult<Self> {
350
356
  let by = rb_exprs_to_exprs(by)?;
351
357
  Ok(self
352
- .clone()
353
358
  .inner
359
+ .clone()
354
360
  .sort_by(
355
361
  by,
356
362
  SortMultipleOptions {
@@ -364,11 +370,11 @@ impl RbExpr {
364
370
  }
365
371
 
366
372
  pub fn backward_fill(&self, limit: FillNullLimit) -> Self {
367
- self.clone().inner.backward_fill(limit).into()
373
+ self.inner.clone().backward_fill(limit).into()
368
374
  }
369
375
 
370
376
  pub fn forward_fill(&self, limit: FillNullLimit) -> Self {
371
- self.clone().inner.forward_fill(limit).into()
377
+ self.inner.clone().forward_fill(limit).into()
372
378
  }
373
379
 
374
380
  pub fn shift(&self, n: &Self, fill_value: Option<&Self>) -> Self {
@@ -381,7 +387,7 @@ impl RbExpr {
381
387
  }
382
388
 
383
389
  pub fn fill_null(&self, expr: &Self) -> Self {
384
- self.clone().inner.fill_null(expr.inner.clone()).into()
390
+ self.inner.clone().fill_null(expr.inner.clone()).into()
385
391
  }
386
392
 
387
393
  pub fn fill_null_with_strategy(
@@ -414,39 +420,46 @@ impl RbExpr {
414
420
  }
415
421
 
416
422
  pub fn filter(&self, predicate: &Self) -> Self {
417
- self.clone().inner.filter(predicate.inner.clone()).into()
423
+ self.inner.clone().filter(predicate.inner.clone()).into()
418
424
  }
419
425
 
420
426
  pub fn reverse(&self) -> Self {
421
- self.clone().inner.reverse().into()
427
+ self.inner.clone().reverse().into()
422
428
  }
423
429
 
424
430
  pub fn std(&self, ddof: u8) -> Self {
425
- self.clone().inner.std(ddof).into()
431
+ self.inner.clone().std(ddof).into()
426
432
  }
427
433
 
428
434
  pub fn var(&self, ddof: u8) -> Self {
429
- self.clone().inner.var(ddof).into()
435
+ self.inner.clone().var(ddof).into()
430
436
  }
431
437
 
432
438
  pub fn is_unique(&self) -> Self {
433
- self.clone().inner.is_unique().into()
439
+ self.inner.clone().is_unique().into()
440
+ }
441
+
442
+ pub fn is_between(&self, lower: &Self, upper: &Self, closed: Wrap<ClosedInterval>) -> Self {
443
+ self.inner
444
+ .clone()
445
+ .is_between(lower.inner.clone(), upper.inner.clone(), closed.0)
446
+ .into()
434
447
  }
435
448
 
436
449
  pub fn approx_n_unique(&self) -> Self {
437
- self.clone().inner.approx_n_unique().into()
450
+ self.inner.clone().approx_n_unique().into()
438
451
  }
439
452
 
440
453
  pub fn is_first_distinct(&self) -> Self {
441
- self.clone().inner.is_first_distinct().into()
454
+ self.inner.clone().is_first_distinct().into()
442
455
  }
443
456
 
444
457
  pub fn is_last_distinct(&self) -> Self {
445
- self.clone().inner.is_last_distinct().into()
458
+ self.inner.clone().is_last_distinct().into()
446
459
  }
447
460
 
448
461
  pub fn explode(&self) -> Self {
449
- self.clone().inner.explode().into()
462
+ self.inner.clone().explode().into()
450
463
  }
451
464
 
452
465
  pub fn gather_every(&self, n: usize, offset: usize) -> Self {
@@ -461,11 +474,11 @@ impl RbExpr {
461
474
  }
462
475
 
463
476
  pub fn tail(&self, n: Option<usize>) -> Self {
464
- self.clone().inner.tail(n).into()
477
+ self.inner.clone().tail(n).into()
465
478
  }
466
479
 
467
480
  pub fn head(&self, n: Option<usize>) -> Self {
468
- self.clone().inner.head(n).into()
481
+ self.inner.clone().head(n).into()
469
482
  }
470
483
 
471
484
  pub fn slice(&self, offset: &Self, length: &Self) -> Self {
@@ -490,15 +503,15 @@ impl RbExpr {
490
503
  }
491
504
 
492
505
  pub fn round(&self, decimals: u32) -> Self {
493
- self.clone().inner.round(decimals).into()
506
+ self.inner.clone().round(decimals).into()
494
507
  }
495
508
 
496
509
  pub fn floor(&self) -> Self {
497
- self.clone().inner.floor().into()
510
+ self.inner.clone().floor().into()
498
511
  }
499
512
 
500
513
  pub fn ceil(&self) -> Self {
501
- self.clone().inner.ceil().into()
514
+ self.inner.clone().ceil().into()
502
515
  }
503
516
 
504
517
  pub fn clip(&self, min: Option<&Self>, max: Option<&Self>) -> Self {
@@ -513,112 +526,112 @@ impl RbExpr {
513
526
  }
514
527
 
515
528
  pub fn abs(&self) -> Self {
516
- self.clone().inner.abs().into()
529
+ self.inner.clone().abs().into()
517
530
  }
518
531
 
519
532
  pub fn sin(&self) -> Self {
520
- self.clone().inner.sin().into()
533
+ self.inner.clone().sin().into()
521
534
  }
522
535
 
523
536
  pub fn cos(&self) -> Self {
524
- self.clone().inner.cos().into()
537
+ self.inner.clone().cos().into()
525
538
  }
526
539
 
527
540
  pub fn tan(&self) -> Self {
528
- self.clone().inner.tan().into()
541
+ self.inner.clone().tan().into()
529
542
  }
530
543
 
531
544
  pub fn arcsin(&self) -> Self {
532
- self.clone().inner.arcsin().into()
545
+ self.inner.clone().arcsin().into()
533
546
  }
534
547
 
535
548
  pub fn arccos(&self) -> Self {
536
- self.clone().inner.arccos().into()
549
+ self.inner.clone().arccos().into()
537
550
  }
538
551
 
539
552
  pub fn arctan(&self) -> Self {
540
- self.clone().inner.arctan().into()
553
+ self.inner.clone().arctan().into()
541
554
  }
542
555
 
543
556
  pub fn sinh(&self) -> Self {
544
- self.clone().inner.sinh().into()
557
+ self.inner.clone().sinh().into()
545
558
  }
546
559
 
547
560
  pub fn cosh(&self) -> Self {
548
- self.clone().inner.cosh().into()
561
+ self.inner.clone().cosh().into()
549
562
  }
550
563
 
551
564
  pub fn tanh(&self) -> Self {
552
- self.clone().inner.tanh().into()
565
+ self.inner.clone().tanh().into()
553
566
  }
554
567
 
555
568
  pub fn arcsinh(&self) -> Self {
556
- self.clone().inner.arcsinh().into()
569
+ self.inner.clone().arcsinh().into()
557
570
  }
558
571
 
559
572
  pub fn arccosh(&self) -> Self {
560
- self.clone().inner.arccosh().into()
573
+ self.inner.clone().arccosh().into()
561
574
  }
562
575
 
563
576
  pub fn arctanh(&self) -> Self {
564
- self.clone().inner.arctanh().into()
577
+ self.inner.clone().arctanh().into()
565
578
  }
566
579
 
567
580
  pub fn sign(&self) -> Self {
568
- self.clone().inner.sign().into()
581
+ self.inner.clone().sign().into()
569
582
  }
570
583
 
571
584
  pub fn is_duplicated(&self) -> Self {
572
- self.clone().inner.is_duplicated().into()
585
+ self.inner.clone().is_duplicated().into()
573
586
  }
574
587
 
575
588
  pub fn over(&self, partition_by: RArray) -> RbResult<Self> {
576
589
  let partition_by = rb_exprs_to_exprs(partition_by)?;
577
- Ok(self.clone().inner.over(partition_by).into())
590
+ Ok(self.inner.clone().over(partition_by).into())
578
591
  }
579
592
 
580
593
  pub fn _and(&self, expr: &Self) -> Self {
581
- self.clone().inner.and(expr.inner.clone()).into()
594
+ self.inner.clone().and(expr.inner.clone()).into()
582
595
  }
583
596
 
584
597
  pub fn _xor(&self, expr: &Self) -> Self {
585
- self.clone().inner.xor(expr.inner.clone()).into()
598
+ self.inner.clone().xor(expr.inner.clone()).into()
586
599
  }
587
600
 
588
601
  pub fn _or(&self, expr: &Self) -> Self {
589
- self.clone().inner.or(expr.inner.clone()).into()
602
+ self.inner.clone().or(expr.inner.clone()).into()
590
603
  }
591
604
 
592
605
  pub fn is_in(&self, expr: &Self) -> Self {
593
- self.clone().inner.is_in(expr.inner.clone()).into()
606
+ self.inner.clone().is_in(expr.inner.clone()).into()
594
607
  }
595
608
 
596
609
  pub fn repeat_by(&self, by: &Self) -> Self {
597
- self.clone().inner.repeat_by(by.inner.clone()).into()
610
+ self.inner.clone().repeat_by(by.inner.clone()).into()
598
611
  }
599
612
 
600
613
  pub fn pow(&self, exponent: &Self) -> Self {
601
- self.clone().inner.pow(exponent.inner.clone()).into()
614
+ self.inner.clone().pow(exponent.inner.clone()).into()
602
615
  }
603
616
 
604
617
  pub fn cum_sum(&self, reverse: bool) -> Self {
605
- self.clone().inner.cum_sum(reverse).into()
618
+ self.inner.clone().cum_sum(reverse).into()
606
619
  }
607
620
 
608
621
  pub fn cum_max(&self, reverse: bool) -> Self {
609
- self.clone().inner.cum_max(reverse).into()
622
+ self.inner.clone().cum_max(reverse).into()
610
623
  }
611
624
 
612
625
  pub fn cum_min(&self, reverse: bool) -> Self {
613
- self.clone().inner.cum_min(reverse).into()
626
+ self.inner.clone().cum_min(reverse).into()
614
627
  }
615
628
 
616
629
  pub fn cum_prod(&self, reverse: bool) -> Self {
617
- self.clone().inner.cum_prod(reverse).into()
630
+ self.inner.clone().cum_prod(reverse).into()
618
631
  }
619
632
 
620
633
  pub fn product(&self) -> Self {
621
- self.clone().inner.product().into()
634
+ self.inner.clone().product().into()
622
635
  }
623
636
 
624
637
  pub fn shrink_dtype(&self) -> Self {
@@ -704,7 +717,7 @@ impl RbExpr {
704
717
  }
705
718
 
706
719
  pub fn reshape(&self, dims: Vec<i64>) -> Self {
707
- self.inner.clone().reshape(&dims).into()
720
+ self.inner.clone().reshape(&dims, NestedType::Array).into()
708
721
  }
709
722
 
710
723
  pub fn cum_count(&self, reverse: bool) -> Self {
@@ -712,14 +725,7 @@ impl RbExpr {
712
725
  }
713
726
 
714
727
  pub fn to_physical(&self) -> Self {
715
- self.inner
716
- .clone()
717
- .map(
718
- |s| Ok(Some(s.to_physical_repr().into_owned())),
719
- GetOutput::map_dtype(|dt| dt.to_physical()),
720
- )
721
- .with_fmt("to_physical")
722
- .into()
728
+ self.inner.clone().to_physical().into()
723
729
  }
724
730
 
725
731
  pub fn shuffle(&self, seed: Option<u64>) -> Self {
@@ -855,7 +861,14 @@ impl RbExpr {
855
861
  self.inner.clone().set_sorted_flag(is_sorted).into()
856
862
  }
857
863
 
858
- pub fn replace(
864
+ pub fn replace(&self, old: &Self, new: &Self) -> Self {
865
+ self.inner
866
+ .clone()
867
+ .replace(old.inner.clone(), new.inner.clone())
868
+ .into()
869
+ }
870
+
871
+ pub fn replace_strict(
859
872
  &self,
860
873
  old: &Self,
861
874
  new: &Self,
@@ -864,7 +877,7 @@ impl RbExpr {
864
877
  ) -> Self {
865
878
  self.inner
866
879
  .clone()
867
- .replace(
880
+ .replace_strict(
868
881
  old.inner.clone(),
869
882
  new.inner.clone(),
870
883
  default.map(|e| e.inner.clone()),
@@ -29,8 +29,8 @@ impl From<Expr> for RbExpr {
29
29
 
30
30
  pub fn rb_exprs_to_exprs(rb_exprs: RArray) -> RbResult<Vec<Expr>> {
31
31
  let mut exprs = Vec::new();
32
- for item in rb_exprs.each() {
33
- exprs.push(<&RbExpr>::try_convert(item?)?.inner.clone());
32
+ for item in rb_exprs.into_iter() {
33
+ exprs.push(<&RbExpr>::try_convert(item)?.inner.clone());
34
34
  }
35
35
  Ok(exprs)
36
36
  }
@@ -9,9 +9,10 @@ impl RbExpr {
9
9
  &self,
10
10
  window_size: usize,
11
11
  weights: Option<Vec<f64>>,
12
- min_periods: usize,
12
+ min_periods: Option<usize>,
13
13
  center: bool,
14
14
  ) -> Self {
15
+ let min_periods = min_periods.unwrap_or(window_size);
15
16
  let options = RollingOptionsFixedWindow {
16
17
  window_size,
17
18
  weights,
@@ -45,9 +46,10 @@ impl RbExpr {
45
46
  &self,
46
47
  window_size: usize,
47
48
  weights: Option<Vec<f64>>,
48
- min_periods: usize,
49
+ min_periods: Option<usize>,
49
50
  center: bool,
50
51
  ) -> Self {
52
+ let min_periods = min_periods.unwrap_or(window_size);
51
53
  let options = RollingOptionsFixedWindow {
52
54
  window_size,
53
55
  weights,
@@ -81,11 +83,12 @@ impl RbExpr {
81
83
  &self,
82
84
  window_size: usize,
83
85
  weights: Option<Vec<f64>>,
84
- min_periods: usize,
86
+ min_periods: Option<usize>,
85
87
  center: bool,
86
88
  ) -> Self {
89
+ let min_periods = min_periods.unwrap_or(window_size);
87
90
  let options = RollingOptionsFixedWindow {
88
- window_size: window_size,
91
+ window_size,
89
92
  weights,
90
93
  min_periods,
91
94
  center,
@@ -117,9 +120,10 @@ impl RbExpr {
117
120
  &self,
118
121
  window_size: usize,
119
122
  weights: Option<Vec<f64>>,
120
- min_periods: usize,
123
+ min_periods: Option<usize>,
121
124
  center: bool,
122
125
  ) -> Self {
126
+ let min_periods = min_periods.unwrap_or(window_size);
123
127
  let options = RollingOptionsFixedWindow {
124
128
  window_size,
125
129
  weights,
@@ -155,10 +159,11 @@ impl RbExpr {
155
159
  &self,
156
160
  window_size: usize,
157
161
  weights: Option<Vec<f64>>,
158
- min_periods: usize,
162
+ min_periods: Option<usize>,
159
163
  center: bool,
160
164
  ddof: u8,
161
165
  ) -> Self {
166
+ let min_periods = min_periods.unwrap_or(window_size);
162
167
  let options = RollingOptionsFixedWindow {
163
168
  window_size,
164
169
  weights,
@@ -195,10 +200,11 @@ impl RbExpr {
195
200
  &self,
196
201
  window_size: usize,
197
202
  weights: Option<Vec<f64>>,
198
- min_periods: usize,
203
+ min_periods: Option<usize>,
199
204
  center: bool,
200
205
  ddof: u8,
201
206
  ) -> Self {
207
+ let min_periods = min_periods.unwrap_or(window_size);
202
208
  let options = RollingOptionsFixedWindow {
203
209
  window_size,
204
210
  weights,
@@ -235,9 +241,10 @@ impl RbExpr {
235
241
  &self,
236
242
  window_size: usize,
237
243
  weights: Option<Vec<f64>>,
238
- min_periods: usize,
244
+ min_periods: Option<usize>,
239
245
  center: bool,
240
246
  ) -> Self {
247
+ let min_periods = min_periods.unwrap_or(window_size);
241
248
  let options = RollingOptionsFixedWindow {
242
249
  window_size,
243
250
  min_periods,
@@ -273,9 +280,10 @@ impl RbExpr {
273
280
  interpolation: Wrap<QuantileInterpolOptions>,
274
281
  window_size: usize,
275
282
  weights: Option<Vec<f64>>,
276
- min_periods: usize,
283
+ min_periods: Option<usize>,
277
284
  center: bool,
278
285
  ) -> Self {
286
+ let min_periods = min_periods.unwrap_or(window_size);
279
287
  let options = RollingOptionsFixedWindow {
280
288
  window_size,
281
289
  weights,
@@ -4,11 +4,11 @@ use crate::conversion::Wrap;
4
4
  use crate::{RbExpr, RbPolarsErr, RbResult};
5
5
 
6
6
  impl RbExpr {
7
- pub fn str_concat(&self, delimiter: String, ignore_nulls: bool) -> Self {
7
+ pub fn str_join(&self, delimiter: String, ignore_nulls: bool) -> Self {
8
8
  self.inner
9
9
  .clone()
10
10
  .str()
11
- .concat(&delimiter, ignore_nulls)
11
+ .join(&delimiter, ignore_nulls)
12
12
  .into()
13
13
  }
14
14
 
@@ -115,10 +115,6 @@ impl RbExpr {
115
115
  .into()
116
116
  }
117
117
 
118
- pub fn str_explode(&self) -> Self {
119
- self.inner.clone().str().explode().into()
120
- }
121
-
122
118
  pub fn str_to_uppercase(&self) -> Self {
123
119
  self.inner.clone().str().to_uppercase().into()
124
120
  }