polars-df 0.5.0 → 0.7.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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/Cargo.lock +595 -709
  4. data/Cargo.toml +1 -0
  5. data/README.md +11 -9
  6. data/ext/polars/Cargo.toml +18 -10
  7. data/ext/polars/src/batched_csv.rs +26 -26
  8. data/ext/polars/src/conversion.rs +272 -136
  9. data/ext/polars/src/dataframe.rs +135 -94
  10. data/ext/polars/src/error.rs +8 -5
  11. data/ext/polars/src/expr/array.rs +15 -0
  12. data/ext/polars/src/expr/binary.rs +18 -6
  13. data/ext/polars/src/expr/datetime.rs +10 -12
  14. data/ext/polars/src/expr/general.rs +78 -264
  15. data/ext/polars/src/expr/list.rs +41 -28
  16. data/ext/polars/src/{expr.rs → expr/mod.rs} +5 -2
  17. data/ext/polars/src/expr/name.rs +44 -0
  18. data/ext/polars/src/expr/rolling.rs +196 -0
  19. data/ext/polars/src/expr/string.rs +94 -66
  20. data/ext/polars/src/file.rs +3 -3
  21. data/ext/polars/src/functions/aggregation.rs +35 -0
  22. data/ext/polars/src/functions/eager.rs +7 -31
  23. data/ext/polars/src/functions/io.rs +10 -10
  24. data/ext/polars/src/functions/lazy.rs +119 -54
  25. data/ext/polars/src/functions/meta.rs +30 -0
  26. data/ext/polars/src/functions/misc.rs +8 -0
  27. data/ext/polars/src/functions/mod.rs +5 -0
  28. data/ext/polars/src/functions/random.rs +6 -0
  29. data/ext/polars/src/functions/range.rs +46 -0
  30. data/ext/polars/src/functions/string_cache.rs +11 -0
  31. data/ext/polars/src/functions/whenthen.rs +7 -7
  32. data/ext/polars/src/lazyframe.rs +61 -44
  33. data/ext/polars/src/lib.rs +173 -84
  34. data/ext/polars/src/{apply → map}/dataframe.rs +28 -33
  35. data/ext/polars/src/{apply → map}/mod.rs +10 -6
  36. data/ext/polars/src/{apply → map}/series.rs +12 -16
  37. data/ext/polars/src/object.rs +2 -2
  38. data/ext/polars/src/rb_modules.rs +25 -6
  39. data/ext/polars/src/series/construction.rs +32 -6
  40. data/ext/polars/src/series/export.rs +2 -2
  41. data/ext/polars/src/series/set_at_idx.rs +33 -17
  42. data/ext/polars/src/series.rs +62 -42
  43. data/ext/polars/src/sql.rs +46 -0
  44. data/lib/polars/array_expr.rb +84 -0
  45. data/lib/polars/array_name_space.rb +77 -0
  46. data/lib/polars/batched_csv_reader.rb +1 -1
  47. data/lib/polars/config.rb +530 -0
  48. data/lib/polars/data_frame.rb +206 -131
  49. data/lib/polars/data_types.rb +163 -29
  50. data/lib/polars/date_time_expr.rb +13 -18
  51. data/lib/polars/date_time_name_space.rb +22 -28
  52. data/lib/polars/dynamic_group_by.rb +2 -2
  53. data/lib/polars/expr.rb +241 -151
  54. data/lib/polars/functions.rb +29 -38
  55. data/lib/polars/group_by.rb +38 -76
  56. data/lib/polars/io.rb +37 -2
  57. data/lib/polars/lazy_frame.rb +174 -95
  58. data/lib/polars/lazy_functions.rb +87 -63
  59. data/lib/polars/lazy_group_by.rb +7 -8
  60. data/lib/polars/list_expr.rb +40 -36
  61. data/lib/polars/list_name_space.rb +15 -15
  62. data/lib/polars/name_expr.rb +198 -0
  63. data/lib/polars/rolling_group_by.rb +6 -4
  64. data/lib/polars/series.rb +95 -28
  65. data/lib/polars/sql_context.rb +194 -0
  66. data/lib/polars/string_expr.rb +249 -69
  67. data/lib/polars/string_name_space.rb +155 -25
  68. data/lib/polars/utils.rb +119 -57
  69. data/lib/polars/version.rb +1 -1
  70. data/lib/polars.rb +6 -0
  71. metadata +21 -7
  72. /data/ext/polars/src/{apply → map}/lazy.rs +0 -0
@@ -1,10 +1,11 @@
1
- use magnus::{block::Proc, IntoValue, RArray, Value};
1
+ use magnus::{prelude::*, value::Opaque, IntoValue, RArray, Ruby, Value};
2
2
  use polars::lazy::dsl;
3
3
  use polars::prelude::*;
4
4
  use polars::series::ops::NullBehavior;
5
+ use polars_core::series::IsSorted;
5
6
 
6
- use crate::apply::lazy::map_single;
7
7
  use crate::conversion::{parse_fill_null_strategy, Wrap};
8
+ use crate::map::lazy::map_single;
8
9
  use crate::rb_exprs_to_exprs;
9
10
  use crate::utils::reinterpret;
10
11
  use crate::{RbExpr, RbResult};
@@ -201,6 +202,7 @@ impl RbExpr {
201
202
  descending,
202
203
  nulls_last,
203
204
  multithreaded: true,
205
+ maintain_order: false,
204
206
  })
205
207
  .into()
206
208
  }
@@ -212,16 +214,25 @@ impl RbExpr {
212
214
  descending: reverse,
213
215
  nulls_last,
214
216
  multithreaded: true,
217
+ maintain_order: false,
215
218
  })
216
219
  .into()
217
220
  }
218
221
 
219
- pub fn top_k(&self, k: usize) -> Self {
220
- self.inner.clone().top_k(k).into()
222
+ pub fn top_k(&self, k: &Self) -> Self {
223
+ self.inner.clone().top_k(k.inner.clone()).into()
221
224
  }
222
225
 
223
- pub fn bottom_k(&self, k: usize) -> Self {
224
- self.inner.clone().bottom_k(k).into()
226
+ pub fn bottom_k(&self, k: &Self) -> Self {
227
+ self.inner.clone().bottom_k(k.inner.clone()).into()
228
+ }
229
+
230
+ pub fn peak_min(&self) -> Self {
231
+ self.inner.clone().peak_min().into()
232
+ }
233
+
234
+ pub fn peak_max(&self) -> Self {
235
+ self.inner.clone().peak_max().into()
225
236
  }
226
237
 
227
238
  pub fn arg_max(&self) -> Self {
@@ -239,8 +250,8 @@ impl RbExpr {
239
250
  .into()
240
251
  }
241
252
 
242
- pub fn take(&self, idx: &RbExpr) -> Self {
243
- self.clone().inner.take(idx.inner.clone()).into()
253
+ pub fn gather(&self, idx: &RbExpr) -> Self {
254
+ self.clone().inner.gather(idx.inner.clone()).into()
244
255
  }
245
256
 
246
257
  pub fn sort_by(&self, by: RArray, reverse: Vec<bool>) -> RbResult<Self> {
@@ -256,14 +267,13 @@ impl RbExpr {
256
267
  self.clone().inner.forward_fill(limit).into()
257
268
  }
258
269
 
259
- pub fn shift(&self, periods: i64) -> Self {
260
- self.clone().inner.shift(periods).into()
261
- }
262
- pub fn shift_and_fill(&self, periods: i64, fill_value: &RbExpr) -> Self {
263
- self.clone()
264
- .inner
265
- .shift_and_fill(periods, fill_value.inner.clone())
266
- .into()
270
+ pub fn shift(&self, n: &Self, fill_value: Option<&Self>) -> Self {
271
+ let expr = self.inner.clone();
272
+ let out = match fill_value {
273
+ Some(v) => expr.shift_and_fill(n.inner.clone(), v.inner.clone()),
274
+ None => expr.shift(n.inner.clone()),
275
+ };
276
+ out.into()
267
277
  }
268
278
 
269
279
  pub fn fill_null(&self, expr: &RbExpr) -> Self {
@@ -319,26 +329,30 @@ impl RbExpr {
319
329
  self.clone().inner.is_unique().into()
320
330
  }
321
331
 
322
- pub fn approx_unique(&self) -> Self {
323
- self.clone().inner.approx_unique().into()
332
+ pub fn approx_n_unique(&self) -> Self {
333
+ self.clone().inner.approx_n_unique().into()
334
+ }
335
+
336
+ pub fn is_first_distinct(&self) -> Self {
337
+ self.clone().inner.is_first_distinct().into()
324
338
  }
325
339
 
326
- pub fn is_first(&self) -> Self {
327
- self.clone().inner.is_first().into()
340
+ pub fn is_last_distinct(&self) -> Self {
341
+ self.clone().inner.is_last_distinct().into()
328
342
  }
329
343
 
330
344
  pub fn explode(&self) -> Self {
331
345
  self.clone().inner.explode().into()
332
346
  }
333
347
 
334
- pub fn take_every(&self, n: usize) -> Self {
348
+ pub fn gather_every(&self, n: usize) -> Self {
335
349
  self.clone()
336
350
  .inner
337
351
  .map(
338
- move |s: Series| Ok(Some(s.take_every(n))),
352
+ move |s: Series| Ok(Some(s.gather_every(n))),
339
353
  GetOutput::same_type(),
340
354
  )
341
- .with_fmt("take_every")
355
+ .with_fmt("gather_every")
342
356
  .into()
343
357
  }
344
358
 
@@ -383,20 +397,15 @@ impl RbExpr {
383
397
  self.clone().inner.ceil().into()
384
398
  }
385
399
 
386
- pub fn clip(&self, min: Value, max: Value) -> Self {
387
- let min = min.try_convert::<Wrap<AnyValue>>().unwrap().0;
388
- let max = max.try_convert::<Wrap<AnyValue>>().unwrap().0;
389
- self.clone().inner.clip(min, max).into()
390
- }
391
-
392
- pub fn clip_min(&self, min: Value) -> Self {
393
- let min = min.try_convert::<Wrap<AnyValue>>().unwrap().0;
394
- self.clone().inner.clip_min(min).into()
395
- }
396
-
397
- pub fn clip_max(&self, max: Value) -> Self {
398
- let max = max.try_convert::<Wrap<AnyValue>>().unwrap().0;
399
- self.clone().inner.clip_max(max).into()
400
+ pub fn clip(&self, min: Option<&Self>, max: Option<&Self>) -> Self {
401
+ let expr = self.inner.clone();
402
+ let out = match (min, max) {
403
+ (Some(min), Some(max)) => expr.clip(min.inner.clone(), max.inner.clone()),
404
+ (Some(min), None) => expr.clip_min(min.inner.clone()),
405
+ (None, Some(max)) => expr.clip_max(max.inner.clone()),
406
+ (None, None) => expr,
407
+ };
408
+ out.into()
400
409
  }
401
410
 
402
411
  pub fn abs(&self) -> Self {
@@ -488,20 +497,20 @@ impl RbExpr {
488
497
  self.clone().inner.pow(exponent.inner.clone()).into()
489
498
  }
490
499
 
491
- pub fn cumsum(&self, reverse: bool) -> Self {
492
- self.clone().inner.cumsum(reverse).into()
500
+ pub fn cum_sum(&self, reverse: bool) -> Self {
501
+ self.clone().inner.cum_sum(reverse).into()
493
502
  }
494
503
 
495
- pub fn cummax(&self, reverse: bool) -> Self {
496
- self.clone().inner.cummax(reverse).into()
504
+ pub fn cum_max(&self, reverse: bool) -> Self {
505
+ self.clone().inner.cum_max(reverse).into()
497
506
  }
498
507
 
499
- pub fn cummin(&self, reverse: bool) -> Self {
500
- self.clone().inner.cummin(reverse).into()
508
+ pub fn cum_min(&self, reverse: bool) -> Self {
509
+ self.clone().inner.cum_min(reverse).into()
501
510
  }
502
511
 
503
- pub fn cumprod(&self, reverse: bool) -> Self {
504
- self.clone().inner.cumprod(reverse).into()
512
+ pub fn cum_prod(&self, reverse: bool) -> Self {
513
+ self.clone().inner.cum_prod(reverse).into()
505
514
  }
506
515
 
507
516
  pub fn product(&self) -> Self {
@@ -537,33 +546,6 @@ impl RbExpr {
537
546
  self.inner.clone().mode().into()
538
547
  }
539
548
 
540
- pub fn keep_name(&self) -> Self {
541
- self.inner.clone().keep_name().into()
542
- }
543
-
544
- pub fn prefix(&self, prefix: String) -> Self {
545
- self.inner.clone().prefix(&prefix).into()
546
- }
547
-
548
- pub fn suffix(&self, suffix: String) -> Self {
549
- self.inner.clone().suffix(&suffix).into()
550
- }
551
-
552
- pub fn map_alias(&self, lambda: Proc) -> Self {
553
- self.inner
554
- .clone()
555
- .map_alias(move |name| {
556
- let out = lambda.call::<_, String>((name,));
557
- match out {
558
- Ok(out) => Ok(out),
559
- Err(e) => Err(PolarsError::ComputeError(
560
- format!("Ruby function in 'map_alias' produced an error: {}.", e).into(),
561
- )),
562
- }
563
- })
564
- .into()
565
- }
566
-
567
549
  pub fn exclude(&self, columns: Vec<String>) -> Self {
568
550
  self.inner.clone().exclude(columns).into()
569
551
  }
@@ -572,185 +554,6 @@ impl RbExpr {
572
554
  self.inner.clone().interpolate(method.0).into()
573
555
  }
574
556
 
575
- pub fn rolling_sum(
576
- &self,
577
- window_size: String,
578
- weights: Option<Vec<f64>>,
579
- min_periods: usize,
580
- center: bool,
581
- by: Option<String>,
582
- closed: Option<Wrap<ClosedWindow>>,
583
- ) -> Self {
584
- let options = RollingOptions {
585
- window_size: Duration::parse(&window_size),
586
- weights,
587
- min_periods,
588
- center,
589
- by,
590
- closed_window: closed.map(|c| c.0),
591
- };
592
- self.inner.clone().rolling_sum(options).into()
593
- }
594
-
595
- pub fn rolling_min(
596
- &self,
597
- window_size: String,
598
- weights: Option<Vec<f64>>,
599
- min_periods: usize,
600
- center: bool,
601
- by: Option<String>,
602
- closed: Option<Wrap<ClosedWindow>>,
603
- ) -> Self {
604
- let options = RollingOptions {
605
- window_size: Duration::parse(&window_size),
606
- weights,
607
- min_periods,
608
- center,
609
- by,
610
- closed_window: closed.map(|c| c.0),
611
- };
612
- self.inner.clone().rolling_min(options).into()
613
- }
614
-
615
- pub fn rolling_max(
616
- &self,
617
- window_size: String,
618
- weights: Option<Vec<f64>>,
619
- min_periods: usize,
620
- center: bool,
621
- by: Option<String>,
622
- closed: Option<Wrap<ClosedWindow>>,
623
- ) -> Self {
624
- let options = RollingOptions {
625
- window_size: Duration::parse(&window_size),
626
- weights,
627
- min_periods,
628
- center,
629
- by,
630
- closed_window: closed.map(|c| c.0),
631
- };
632
- self.inner.clone().rolling_max(options).into()
633
- }
634
-
635
- pub fn rolling_mean(
636
- &self,
637
- window_size: String,
638
- weights: Option<Vec<f64>>,
639
- min_periods: usize,
640
- center: bool,
641
- by: Option<String>,
642
- closed: Option<Wrap<ClosedWindow>>,
643
- ) -> Self {
644
- let options = RollingOptions {
645
- window_size: Duration::parse(&window_size),
646
- weights,
647
- min_periods,
648
- center,
649
- by,
650
- closed_window: closed.map(|c| c.0),
651
- };
652
-
653
- self.inner.clone().rolling_mean(options).into()
654
- }
655
-
656
- pub fn rolling_std(
657
- &self,
658
- window_size: String,
659
- weights: Option<Vec<f64>>,
660
- min_periods: usize,
661
- center: bool,
662
- by: Option<String>,
663
- closed: Option<Wrap<ClosedWindow>>,
664
- ) -> Self {
665
- let options = RollingOptions {
666
- window_size: Duration::parse(&window_size),
667
- weights,
668
- min_periods,
669
- center,
670
- by,
671
- closed_window: closed.map(|c| c.0),
672
- };
673
-
674
- self.inner.clone().rolling_std(options).into()
675
- }
676
-
677
- pub fn rolling_var(
678
- &self,
679
- window_size: String,
680
- weights: Option<Vec<f64>>,
681
- min_periods: usize,
682
- center: bool,
683
- by: Option<String>,
684
- closed: Option<Wrap<ClosedWindow>>,
685
- ) -> Self {
686
- let options = RollingOptions {
687
- window_size: Duration::parse(&window_size),
688
- weights,
689
- min_periods,
690
- center,
691
- by,
692
- closed_window: closed.map(|c| c.0),
693
- };
694
-
695
- self.inner.clone().rolling_var(options).into()
696
- }
697
-
698
- pub fn rolling_median(
699
- &self,
700
- window_size: String,
701
- weights: Option<Vec<f64>>,
702
- min_periods: usize,
703
- center: bool,
704
- by: Option<String>,
705
- closed: Option<Wrap<ClosedWindow>>,
706
- ) -> Self {
707
- let options = RollingOptions {
708
- window_size: Duration::parse(&window_size),
709
- weights,
710
- min_periods,
711
- center,
712
- by,
713
- closed_window: closed.map(|c| c.0),
714
- };
715
- self.inner.clone().rolling_median(options).into()
716
- }
717
-
718
- #[allow(clippy::too_many_arguments)]
719
- pub fn rolling_quantile(
720
- &self,
721
- quantile: f64,
722
- interpolation: Wrap<QuantileInterpolOptions>,
723
- window_size: String,
724
- weights: Option<Vec<f64>>,
725
- min_periods: usize,
726
- center: bool,
727
- by: Option<String>,
728
- closed: Option<Wrap<ClosedWindow>>,
729
- ) -> Self {
730
- let options = RollingOptions {
731
- window_size: Duration::parse(&window_size),
732
- weights,
733
- min_periods,
734
- center,
735
- by,
736
- closed_window: closed.map(|c| c.0),
737
- };
738
-
739
- self.inner
740
- .clone()
741
- .rolling_quantile(quantile, interpolation.0, options)
742
- .into()
743
- }
744
-
745
- pub fn rolling_skew(&self, window_size: usize, bias: bool) -> Self {
746
- self.inner
747
- .clone()
748
- .rolling_apply_float(window_size, move |ca| {
749
- ca.clone().into_series().skew(bias).unwrap()
750
- })
751
- .into()
752
- }
753
-
754
557
  pub fn lower_bound(&self) -> Self {
755
558
  self.inner.clone().lower_bound().into()
756
559
  }
@@ -778,8 +581,8 @@ impl RbExpr {
778
581
  self.inner.clone().diff(n, null_behavior.0).into()
779
582
  }
780
583
 
781
- pub fn pct_change(&self, n: i64) -> Self {
782
- self.inner.clone().pct_change(n).into()
584
+ pub fn pct_change(&self, n: &Self) -> Self {
585
+ self.inner.clone().pct_change(n.inner.clone()).into()
783
586
  }
784
587
 
785
588
  pub fn skew(&self, bias: bool) -> Self {
@@ -794,8 +597,8 @@ impl RbExpr {
794
597
  self.inner.clone().reshape(&dims).into()
795
598
  }
796
599
 
797
- pub fn cumcount(&self, reverse: bool) -> Self {
798
- self.inner.clone().cumcount(reverse).into()
600
+ pub fn cum_count(&self, reverse: bool) -> Self {
601
+ self.inner.clone().cum_count(reverse).into()
799
602
  }
800
603
 
801
604
  pub fn to_physical(&self) -> Self {
@@ -815,27 +618,27 @@ impl RbExpr {
815
618
 
816
619
  pub fn sample_n(
817
620
  &self,
818
- n: usize,
621
+ n: &Self,
819
622
  with_replacement: bool,
820
623
  shuffle: bool,
821
624
  seed: Option<u64>,
822
625
  ) -> Self {
823
626
  self.inner
824
627
  .clone()
825
- .sample_n(n, with_replacement, shuffle, seed)
628
+ .sample_n(n.inner.clone(), with_replacement, shuffle, seed)
826
629
  .into()
827
630
  }
828
631
 
829
632
  pub fn sample_frac(
830
633
  &self,
831
- frac: f64,
634
+ frac: &Self,
832
635
  with_replacement: bool,
833
636
  shuffle: bool,
834
637
  seed: Option<u64>,
835
638
  ) -> Self {
836
639
  self.inner
837
640
  .clone()
838
- .sample_frac(frac, with_replacement, shuffle, seed)
641
+ .sample_frac(frac.inner.clone(), with_replacement, shuffle, seed)
839
642
  .into()
840
643
  }
841
644
 
@@ -894,11 +697,13 @@ impl RbExpr {
894
697
 
895
698
  pub fn extend_constant(&self, value: Wrap<AnyValue>, n: usize) -> Self {
896
699
  let value = value.into_value();
700
+ let value = Opaque::from(value);
897
701
  self.inner
898
702
  .clone()
899
703
  .apply(
900
704
  move |s| {
901
- let value = value.try_convert::<Wrap<AnyValue>>().unwrap().0;
705
+ let value = Ruby::get().unwrap().get_inner(value);
706
+ let value = Wrap::<AnyValue>::try_convert(value).unwrap().0;
902
707
  s.extend_constant(value, n).map(Some)
903
708
  },
904
709
  GetOutput::same_type(),
@@ -907,12 +712,12 @@ impl RbExpr {
907
712
  .into()
908
713
  }
909
714
 
910
- pub fn any(&self) -> Self {
911
- self.inner.clone().any().into()
715
+ pub fn any(&self, drop_nulls: bool) -> Self {
716
+ self.inner.clone().any(drop_nulls).into()
912
717
  }
913
718
 
914
- pub fn all(&self) -> Self {
915
- self.inner.clone().all().into()
719
+ pub fn all(&self, drop_nulls: bool) -> Self {
720
+ self.inner.clone().all(drop_nulls).into()
916
721
  }
917
722
 
918
723
  pub fn log(&self, base: f64) -> Self {
@@ -930,4 +735,13 @@ impl RbExpr {
930
735
  pub fn hash(&self, seed: u64, seed_1: u64, seed_2: u64, seed_3: u64) -> Self {
931
736
  self.inner.clone().hash(seed, seed_1, seed_2, seed_3).into()
932
737
  }
738
+
739
+ pub fn set_sorted_flag(&self, descending: bool) -> Self {
740
+ let is_sorted = if descending {
741
+ IsSorted::Descending
742
+ } else {
743
+ IsSorted::Ascending
744
+ };
745
+ self.inner.clone().set_sorted_flag(is_sorted).into()
746
+ }
933
747
  }
@@ -8,71 +8,84 @@ use crate::{RbExpr, RbResult};
8
8
 
9
9
  impl RbExpr {
10
10
  pub fn list_arg_max(&self) -> Self {
11
- self.inner.clone().arr().arg_max().into()
11
+ self.inner.clone().list().arg_max().into()
12
12
  }
13
13
 
14
14
  pub fn list_arg_min(&self) -> Self {
15
- self.inner.clone().arr().arg_min().into()
15
+ self.inner.clone().list().arg_min().into()
16
16
  }
17
17
 
18
18
  pub fn list_contains(&self, other: &RbExpr) -> Self {
19
19
  self.inner
20
20
  .clone()
21
- .arr()
21
+ .list()
22
22
  .contains(other.inner.clone())
23
23
  .into()
24
24
  }
25
25
 
26
- pub fn list_count_match(&self, expr: &RbExpr) -> Self {
26
+ pub fn list_count_matches(&self, expr: &RbExpr) -> Self {
27
27
  self.inner
28
28
  .clone()
29
- .arr()
30
- .count_match(expr.inner.clone())
29
+ .list()
30
+ .count_matches(expr.inner.clone())
31
31
  .into()
32
32
  }
33
33
 
34
34
  pub fn list_diff(&self, n: i64, null_behavior: Wrap<NullBehavior>) -> RbResult<Self> {
35
- Ok(self.inner.clone().arr().diff(n, null_behavior.0).into())
35
+ Ok(self.inner.clone().list().diff(n, null_behavior.0).into())
36
36
  }
37
37
 
38
38
  pub fn list_eval(&self, expr: &RbExpr, parallel: bool) -> Self {
39
39
  self.inner
40
40
  .clone()
41
- .arr()
41
+ .list()
42
42
  .eval(expr.inner.clone(), parallel)
43
43
  .into()
44
44
  }
45
45
 
46
46
  pub fn list_get(&self, index: &RbExpr) -> Self {
47
- self.inner.clone().arr().get(index.inner.clone()).into()
47
+ self.inner.clone().list().get(index.inner.clone()).into()
48
48
  }
49
49
 
50
- pub fn list_join(&self, separator: String) -> Self {
51
- self.inner.clone().arr().join(&separator).into()
50
+ pub fn list_join(&self, separator: &RbExpr) -> Self {
51
+ self.inner
52
+ .clone()
53
+ .list()
54
+ .join(separator.inner.clone())
55
+ .into()
52
56
  }
53
57
 
54
- pub fn list_lengths(&self) -> Self {
55
- self.inner.clone().arr().lengths().into()
58
+ pub fn list_len(&self) -> Self {
59
+ self.inner.clone().list().len().into()
56
60
  }
57
61
 
58
62
  pub fn list_max(&self) -> Self {
59
- self.inner.clone().arr().max().into()
63
+ self.inner.clone().list().max().into()
60
64
  }
61
65
 
62
66
  pub fn list_mean(&self) -> Self {
63
- self.inner.clone().arr().mean().with_fmt("arr.mean").into()
67
+ self.inner
68
+ .clone()
69
+ .list()
70
+ .mean()
71
+ .with_fmt("list.mean")
72
+ .into()
64
73
  }
65
74
 
66
75
  pub fn list_min(&self) -> Self {
67
- self.inner.clone().arr().min().into()
76
+ self.inner.clone().list().min().into()
68
77
  }
69
78
 
70
79
  pub fn list_reverse(&self) -> Self {
71
- self.inner.clone().arr().reverse().into()
80
+ self.inner.clone().list().reverse().into()
72
81
  }
73
82
 
74
- pub fn list_shift(&self, periods: i64) -> Self {
75
- self.inner.clone().arr().shift(periods).into()
83
+ pub fn list_shift(&self, periods: &RbExpr) -> Self {
84
+ self.inner
85
+ .clone()
86
+ .list()
87
+ .shift(periods.inner.clone())
88
+ .into()
76
89
  }
77
90
 
78
91
  pub fn list_slice(&self, offset: &RbExpr, length: Option<&RbExpr>) -> Self {
@@ -82,7 +95,7 @@ impl RbExpr {
82
95
  };
83
96
  self.inner
84
97
  .clone()
85
- .arr()
98
+ .list()
86
99
  .slice(offset.inner.clone(), length)
87
100
  .into()
88
101
  }
@@ -90,23 +103,23 @@ impl RbExpr {
90
103
  pub fn list_sort(&self, reverse: bool) -> Self {
91
104
  self.inner
92
105
  .clone()
93
- .arr()
106
+ .list()
94
107
  .sort(SortOptions {
95
108
  descending: reverse,
96
109
  ..Default::default()
97
110
  })
98
- .with_fmt("arr.sort")
111
+ .with_fmt("list.sort")
99
112
  .into()
100
113
  }
101
114
 
102
115
  pub fn list_sum(&self) -> Self {
103
- self.inner.clone().arr().sum().with_fmt("arr.sum").into()
116
+ self.inner.clone().list().sum().with_fmt("list.sum").into()
104
117
  }
105
118
 
106
119
  pub fn list_take(&self, index: &RbExpr, null_on_oob: bool) -> Self {
107
120
  self.inner
108
121
  .clone()
109
- .arr()
122
+ .list()
110
123
  .take(index.inner.clone(), null_on_oob)
111
124
  .into()
112
125
  }
@@ -122,14 +135,14 @@ impl RbExpr {
122
135
  // let name_gen = name_gen.map(|lambda| {
123
136
  // Arc::new(move |idx: usize| {
124
137
  // let out: Value = lambda.funcall("call", (idx,)).unwrap();
125
- // out.try_convert::<String>().unwrap()
138
+ // String::try_convert(out).unwrap()
126
139
  // }) as NameGenerator
127
140
  // });
128
141
 
129
142
  Ok(self
130
143
  .inner
131
144
  .clone()
132
- .arr()
145
+ .list()
133
146
  .to_struct(width_strat.0, name_gen, upper_bound)
134
147
  .into())
135
148
  }
@@ -138,9 +151,9 @@ impl RbExpr {
138
151
  let e = self.inner.clone();
139
152
 
140
153
  if maintain_order {
141
- e.arr().unique_stable().into()
154
+ e.list().unique_stable().into()
142
155
  } else {
143
- e.arr().unique().into()
156
+ e.list().unique().into()
144
157
  }
145
158
  }
146
159
  }
@@ -1,13 +1,16 @@
1
+ mod array;
1
2
  mod binary;
2
3
  mod categorical;
3
4
  mod datetime;
4
5
  mod general;
5
6
  mod list;
6
7
  mod meta;
8
+ mod name;
9
+ mod rolling;
7
10
  mod string;
8
11
  mod r#struct;
9
12
 
10
- use magnus::RArray;
13
+ use magnus::{prelude::*, RArray};
11
14
  use polars::lazy::dsl::Expr;
12
15
 
13
16
  use crate::RbResult;
@@ -27,7 +30,7 @@ impl From<Expr> for RbExpr {
27
30
  pub fn rb_exprs_to_exprs(rb_exprs: RArray) -> RbResult<Vec<Expr>> {
28
31
  let mut exprs = Vec::new();
29
32
  for item in rb_exprs.each() {
30
- exprs.push(item?.try_convert::<&RbExpr>()?.inner.clone());
33
+ exprs.push(<&RbExpr>::try_convert(item?)?.inner.clone());
31
34
  }
32
35
  Ok(exprs)
33
36
  }