polars-df 0.2.5 → 0.3.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.
@@ -1,5 +1,5 @@
1
1
  use magnus::block::Proc;
2
- use magnus::{class, RArray, RString, Value};
2
+ use magnus::{class, IntoValue, RArray, RString, Value};
3
3
  use polars::chunked_array::ops::SortOptions;
4
4
  use polars::lazy::dsl;
5
5
  use polars::lazy::dsl::Operator;
@@ -214,6 +214,7 @@ impl RbExpr {
214
214
  .sort_with(SortOptions {
215
215
  descending,
216
216
  nulls_last,
217
+ multithreaded: true,
217
218
  })
218
219
  .into()
219
220
  }
@@ -224,6 +225,7 @@ impl RbExpr {
224
225
  .arg_sort(SortOptions {
225
226
  descending: reverse,
226
227
  nulls_last,
228
+ multithreaded: true,
227
229
  })
228
230
  .into()
229
231
  }
@@ -240,10 +242,10 @@ impl RbExpr {
240
242
  self.clone().inner.arg_min().into()
241
243
  }
242
244
 
243
- pub fn search_sorted(&self, element: &RbExpr) -> Self {
245
+ pub fn search_sorted(&self, element: &RbExpr, side: Wrap<SearchSortedSide>) -> Self {
244
246
  self.inner
245
247
  .clone()
246
- .search_sorted(element.inner.clone())
248
+ .search_sorted(element.inner.clone(), side.0)
247
249
  .into()
248
250
  }
249
251
 
@@ -287,7 +289,10 @@ impl RbExpr {
287
289
  Ok(self
288
290
  .inner
289
291
  .clone()
290
- .apply(move |s| s.fill_null(strat), GetOutput::same_type())
292
+ .apply(
293
+ move |s| s.fill_null(strat).map(Some),
294
+ GetOutput::same_type(),
295
+ )
291
296
  .with_fmt("fill_null_with_strategy")
292
297
  .into())
293
298
  }
@@ -335,7 +340,10 @@ impl RbExpr {
335
340
  pub fn take_every(&self, n: usize) -> Self {
336
341
  self.clone()
337
342
  .inner
338
- .map(move |s: Series| Ok(s.take_every(n)), GetOutput::same_type())
343
+ .map(
344
+ move |s: Series| Ok(Some(s.take_every(n))),
345
+ GetOutput::same_type(),
346
+ )
339
347
  .with_fmt("take_every")
340
348
  .into()
341
349
  }
@@ -365,7 +373,7 @@ impl RbExpr {
365
373
  pub fn rechunk(&self) -> Self {
366
374
  self.inner
367
375
  .clone()
368
- .map(|s| Ok(s.rechunk()), GetOutput::same_type())
376
+ .map(|s| Ok(Some(s.rechunk())), GetOutput::same_type())
369
377
  .into()
370
378
  }
371
379
 
@@ -527,6 +535,7 @@ impl RbExpr {
527
535
  exact,
528
536
  cache,
529
537
  tz_aware: false,
538
+ utc: false,
530
539
  })
531
540
  .into()
532
541
  }
@@ -538,6 +547,7 @@ impl RbExpr {
538
547
  exact: bool,
539
548
  cache: bool,
540
549
  tz_aware: bool,
550
+ utc: bool,
541
551
  ) -> Self {
542
552
  let tu = match fmt {
543
553
  Some(ref fmt) => {
@@ -565,6 +575,7 @@ impl RbExpr {
565
575
  exact,
566
576
  cache,
567
577
  tz_aware,
578
+ utc,
568
579
  })
569
580
  .into()
570
581
  }
@@ -586,26 +597,27 @@ impl RbExpr {
586
597
  exact,
587
598
  cache,
588
599
  tz_aware: false,
600
+ utc: false,
589
601
  })
590
602
  .into()
591
603
  }
592
604
 
593
- pub fn str_strip(&self, matches: Option<char>) -> Self {
605
+ pub fn str_strip(&self, matches: Option<String>) -> Self {
594
606
  self.inner.clone().str().strip(matches).into()
595
607
  }
596
608
 
597
- pub fn str_rstrip(&self, matches: Option<char>) -> Self {
609
+ pub fn str_rstrip(&self, matches: Option<String>) -> Self {
598
610
  self.inner.clone().str().rstrip(matches).into()
599
611
  }
600
612
 
601
- pub fn str_lstrip(&self, matches: Option<char>) -> Self {
613
+ pub fn str_lstrip(&self, matches: Option<String>) -> Self {
602
614
  self.inner.clone().str().lstrip(matches).into()
603
615
  }
604
616
 
605
617
  pub fn str_slice(&self, start: i64, length: Option<u64>) -> Self {
606
618
  let function = move |s: Series| {
607
619
  let ca = s.utf8()?;
608
- Ok(ca.str_slice(start, length)?.into_series())
620
+ Ok(Some(ca.str_slice(start, length)?.into_series()))
609
621
  };
610
622
  self.clone()
611
623
  .inner
@@ -625,7 +637,7 @@ impl RbExpr {
625
637
  pub fn str_lengths(&self) -> Self {
626
638
  let function = |s: Series| {
627
639
  let ca = s.utf8()?;
628
- Ok(ca.str_lengths().into_series())
640
+ Ok(Some(ca.str_lengths().into_series()))
629
641
  };
630
642
  self.clone()
631
643
  .inner
@@ -637,7 +649,7 @@ impl RbExpr {
637
649
  pub fn str_n_chars(&self) -> Self {
638
650
  let function = |s: Series| {
639
651
  let ca = s.utf8()?;
640
- Ok(ca.str_n_chars().into_series())
652
+ Ok(Some(ca.str_n_chars().into_series()))
641
653
  };
642
654
  self.clone()
643
655
  .inner
@@ -674,37 +686,51 @@ impl RbExpr {
674
686
  self.clone().inner.str().rjust(width, fillchar).into()
675
687
  }
676
688
 
677
- pub fn str_contains(&self, pat: String, literal: Option<bool>) -> Self {
689
+ pub fn str_contains(&self, pat: &RbExpr, literal: Option<bool>, strict: bool) -> Self {
678
690
  match literal {
679
- Some(true) => self.inner.clone().str().contains_literal(pat).into(),
680
- _ => self.inner.clone().str().contains(pat).into(),
691
+ Some(true) => self
692
+ .inner
693
+ .clone()
694
+ .str()
695
+ .contains_literal(pat.inner.clone())
696
+ .into(),
697
+ _ => self
698
+ .inner
699
+ .clone()
700
+ .str()
701
+ .contains(pat.inner.clone(), strict)
702
+ .into(),
681
703
  }
682
704
  }
683
705
 
684
- pub fn str_ends_with(&self, sub: String) -> Self {
685
- self.inner.clone().str().ends_with(sub).into()
706
+ pub fn str_ends_with(&self, sub: &RbExpr) -> Self {
707
+ self.inner.clone().str().ends_with(sub.inner.clone()).into()
686
708
  }
687
709
 
688
- pub fn str_starts_with(&self, sub: String) -> Self {
689
- self.inner.clone().str().starts_with(sub).into()
710
+ pub fn str_starts_with(&self, sub: &RbExpr) -> Self {
711
+ self.inner
712
+ .clone()
713
+ .str()
714
+ .starts_with(sub.inner.clone())
715
+ .into()
690
716
  }
691
717
 
692
718
  pub fn str_hex_encode(&self) -> Self {
693
719
  self.clone()
694
720
  .inner
695
721
  .map(
696
- move |s| s.utf8().map(|s| s.hex_encode().into_series()),
722
+ move |s| s.utf8().map(|s| Some(s.hex_encode().into_series())),
697
723
  GetOutput::same_type(),
698
724
  )
699
725
  .with_fmt("str.hex_encode")
700
726
  .into()
701
727
  }
702
728
 
703
- pub fn str_hex_decode(&self, strict: Option<bool>) -> Self {
729
+ pub fn str_hex_decode(&self, strict: bool) -> Self {
704
730
  self.clone()
705
731
  .inner
706
732
  .map(
707
- move |s| s.utf8()?.hex_decode(strict).map(|s| s.into_series()),
733
+ move |s| s.utf8()?.hex_decode(strict).map(|s| Some(s.into_series())),
708
734
  GetOutput::same_type(),
709
735
  )
710
736
  .with_fmt("str.hex_decode")
@@ -715,18 +741,22 @@ impl RbExpr {
715
741
  self.clone()
716
742
  .inner
717
743
  .map(
718
- move |s| s.utf8().map(|s| s.base64_encode().into_series()),
744
+ move |s| s.utf8().map(|s| Some(s.base64_encode().into_series())),
719
745
  GetOutput::same_type(),
720
746
  )
721
747
  .with_fmt("str.base64_encode")
722
748
  .into()
723
749
  }
724
750
 
725
- pub fn str_base64_decode(&self, strict: Option<bool>) -> Self {
751
+ pub fn str_base64_decode(&self, strict: bool) -> Self {
726
752
  self.clone()
727
753
  .inner
728
754
  .map(
729
- move |s| s.utf8()?.base64_decode(strict).map(|s| s.into_series()),
755
+ move |s| {
756
+ s.utf8()?
757
+ .base64_decode(strict)
758
+ .map(|s| Some(s.into_series()))
759
+ },
730
760
  GetOutput::same_type(),
731
761
  )
732
762
  .with_fmt("str.base64_decode")
@@ -737,7 +767,7 @@ impl RbExpr {
737
767
  let function = move |s: Series| {
738
768
  let ca = s.utf8()?;
739
769
  match ca.json_path_match(&pat) {
740
- Ok(ca) => Ok(ca.into_series()),
770
+ Ok(ca) => Ok(Some(ca.into_series())),
741
771
  Err(e) => Err(PolarsError::ComputeError(format!("{:?}", e).into())),
742
772
  }
743
773
  };
@@ -864,7 +894,7 @@ impl RbExpr {
864
894
  self.inner
865
895
  .clone()
866
896
  .map(
867
- |s| Ok(s.duration()?.days().into_series()),
897
+ |s| Ok(Some(s.duration()?.days().into_series())),
868
898
  GetOutput::from_type(DataType::Int64),
869
899
  )
870
900
  .into()
@@ -874,7 +904,7 @@ impl RbExpr {
874
904
  self.inner
875
905
  .clone()
876
906
  .map(
877
- |s| Ok(s.duration()?.hours().into_series()),
907
+ |s| Ok(Some(s.duration()?.hours().into_series())),
878
908
  GetOutput::from_type(DataType::Int64),
879
909
  )
880
910
  .into()
@@ -884,7 +914,7 @@ impl RbExpr {
884
914
  self.inner
885
915
  .clone()
886
916
  .map(
887
- |s| Ok(s.duration()?.minutes().into_series()),
917
+ |s| Ok(Some(s.duration()?.minutes().into_series())),
888
918
  GetOutput::from_type(DataType::Int64),
889
919
  )
890
920
  .into()
@@ -894,7 +924,7 @@ impl RbExpr {
894
924
  self.inner
895
925
  .clone()
896
926
  .map(
897
- |s| Ok(s.duration()?.seconds().into_series()),
927
+ |s| Ok(Some(s.duration()?.seconds().into_series())),
898
928
  GetOutput::from_type(DataType::Int64),
899
929
  )
900
930
  .into()
@@ -904,7 +934,7 @@ impl RbExpr {
904
934
  self.inner
905
935
  .clone()
906
936
  .map(
907
- |s| Ok(s.duration()?.nanoseconds().into_series()),
937
+ |s| Ok(Some(s.duration()?.nanoseconds().into_series())),
908
938
  GetOutput::from_type(DataType::Int64),
909
939
  )
910
940
  .into()
@@ -914,7 +944,7 @@ impl RbExpr {
914
944
  self.inner
915
945
  .clone()
916
946
  .map(
917
- |s| Ok(s.duration()?.microseconds().into_series()),
947
+ |s| Ok(Some(s.duration()?.microseconds().into_series())),
918
948
  GetOutput::from_type(DataType::Int64),
919
949
  )
920
950
  .into()
@@ -924,7 +954,7 @@ impl RbExpr {
924
954
  self.inner
925
955
  .clone()
926
956
  .map(
927
- |s| Ok(s.duration()?.milliseconds().into_series()),
957
+ |s| Ok(Some(s.duration()?.milliseconds().into_series())),
928
958
  GetOutput::from_type(DataType::Int64),
929
959
  )
930
960
  .into()
@@ -945,7 +975,7 @@ impl RbExpr {
945
975
  .map(
946
976
  |s| {
947
977
  s.timestamp(TimeUnit::Milliseconds)
948
- .map(|ca| (ca / 1000).into_series())
978
+ .map(|ca| Some((ca / 1000).into_series()))
949
979
  },
950
980
  GetOutput::from_type(DataType::Int64),
951
981
  )
@@ -956,18 +986,19 @@ impl RbExpr {
956
986
  self.inner.clone().dt().with_time_unit(tu.0).into()
957
987
  }
958
988
 
959
- pub fn dt_with_time_zone(&self, tz: Option<TimeZone>) -> Self {
960
- self.inner.clone().dt().with_time_zone(tz).into()
989
+ pub fn dt_convert_time_zone(&self, tz: TimeZone) -> Self {
990
+ self.inner.clone().dt().convert_time_zone(tz).into()
961
991
  }
962
992
 
963
993
  pub fn dt_cast_time_unit(&self, tu: Wrap<TimeUnit>) -> Self {
964
994
  self.inner.clone().dt().cast_time_unit(tu.0).into()
965
995
  }
966
996
 
967
- pub fn dt_cast_time_zone(&self, tz: String) -> Self {
968
- self.inner.clone().dt().cast_time_zone(tz).into()
997
+ pub fn dt_replace_time_zone(&self, tz: Option<String>) -> Self {
998
+ self.inner.clone().dt().replace_time_zone(tz).into()
969
999
  }
970
1000
 
1001
+ #[allow(deprecated)]
971
1002
  pub fn dt_tz_localize(&self, tz: String) -> Self {
972
1003
  self.inner.clone().dt().tz_localize(tz).into()
973
1004
  }
@@ -989,7 +1020,7 @@ impl RbExpr {
989
1020
  }
990
1021
 
991
1022
  pub fn reinterpret(&self, signed: bool) -> Self {
992
- let function = move |s: Series| reinterpret(&s, signed);
1023
+ let function = move |s: Series| reinterpret(&s, signed).map(Some);
993
1024
  let dt = if signed {
994
1025
  DataType::Int64
995
1026
  } else {
@@ -1391,7 +1422,7 @@ impl RbExpr {
1391
1422
  self.inner
1392
1423
  .clone()
1393
1424
  .map(
1394
- |s| Ok(s.to_physical_repr().into_owned()),
1425
+ |s| Ok(Some(s.to_physical_repr().into_owned())),
1395
1426
  GetOutput::map_dtype(|dt| dt.to_physical()),
1396
1427
  )
1397
1428
  .with_fmt("to_physical")
@@ -1428,44 +1459,67 @@ impl RbExpr {
1428
1459
  .into()
1429
1460
  }
1430
1461
 
1431
- pub fn ewm_mean(&self, alpha: f64, adjust: bool, min_periods: usize) -> Self {
1462
+ pub fn ewm_mean(
1463
+ &self,
1464
+ alpha: f64,
1465
+ adjust: bool,
1466
+ min_periods: usize,
1467
+ ignore_nulls: bool,
1468
+ ) -> Self {
1432
1469
  let options = EWMOptions {
1433
1470
  alpha,
1434
1471
  adjust,
1435
1472
  bias: false,
1436
1473
  min_periods,
1474
+ ignore_nulls,
1437
1475
  };
1438
1476
  self.inner.clone().ewm_mean(options).into()
1439
1477
  }
1440
1478
 
1441
- pub fn ewm_std(&self, alpha: f64, adjust: bool, bias: bool, min_periods: usize) -> Self {
1479
+ pub fn ewm_std(
1480
+ &self,
1481
+ alpha: f64,
1482
+ adjust: bool,
1483
+ bias: bool,
1484
+ min_periods: usize,
1485
+ ignore_nulls: bool,
1486
+ ) -> Self {
1442
1487
  let options = EWMOptions {
1443
1488
  alpha,
1444
1489
  adjust,
1445
1490
  bias,
1446
1491
  min_periods,
1492
+ ignore_nulls,
1447
1493
  };
1448
1494
  self.inner.clone().ewm_std(options).into()
1449
1495
  }
1450
1496
 
1451
- pub fn ewm_var(&self, alpha: f64, adjust: bool, bias: bool, min_periods: usize) -> Self {
1497
+ pub fn ewm_var(
1498
+ &self,
1499
+ alpha: f64,
1500
+ adjust: bool,
1501
+ bias: bool,
1502
+ min_periods: usize,
1503
+ ignore_nulls: bool,
1504
+ ) -> Self {
1452
1505
  let options = EWMOptions {
1453
1506
  alpha,
1454
1507
  adjust,
1455
1508
  bias,
1456
1509
  min_periods,
1510
+ ignore_nulls,
1457
1511
  };
1458
1512
  self.inner.clone().ewm_var(options).into()
1459
1513
  }
1460
1514
 
1461
1515
  pub fn extend_constant(&self, value: Wrap<AnyValue>, n: usize) -> Self {
1462
- let value = Value::from(value);
1516
+ let value = value.into_value();
1463
1517
  self.inner
1464
1518
  .clone()
1465
1519
  .apply(
1466
1520
  move |s| {
1467
1521
  let value = value.try_convert::<Wrap<AnyValue>>().unwrap().0;
1468
- s.extend_constant(value, n)
1522
+ s.extend_constant(value, n).map(Some)
1469
1523
  },
1470
1524
  GetOutput::same_type(),
1471
1525
  )
@@ -1,14 +1,15 @@
1
- use crate::{RbExpr, RbPolarsErr, RbResult};
1
+ use crate::{RArray, RbExpr, RbPolarsErr, RbResult};
2
2
 
3
3
  impl RbExpr {
4
- pub fn meta_pop(&self) -> Vec<RbExpr> {
5
- self.inner
6
- .clone()
7
- .meta()
8
- .pop()
9
- .into_iter()
10
- .map(RbExpr::from)
11
- .collect()
4
+ pub fn meta_pop(&self) -> RArray {
5
+ RArray::from_iter(
6
+ self.inner
7
+ .clone()
8
+ .meta()
9
+ .pop()
10
+ .into_iter()
11
+ .map(RbExpr::from),
12
+ )
12
13
  }
13
14
 
14
15
  pub fn meta_eq(&self, other: &RbExpr) -> bool {
@@ -21,7 +21,7 @@ use file::get_file_like;
21
21
  use lazy::dataframe::{RbLazyFrame, RbLazyGroupBy};
22
22
  use lazy::dsl::{RbExpr, RbWhen, RbWhenThen};
23
23
  use lazy::utils::rb_exprs_to_exprs;
24
- use magnus::{define_module, function, method, prelude::*, Error, RArray, RHash, Value};
24
+ use magnus::{define_module, function, method, prelude::*, Error, IntoValue, RArray, RHash, Value};
25
25
  use polars::datatypes::{DataType, TimeUnit, IDX_DTYPE};
26
26
  use polars::error::PolarsResult;
27
27
  use polars::frame::DataFrame;
@@ -146,7 +146,7 @@ fn init() -> RbResult<()> {
146
146
  class.define_method("with_row_count", method!(RbDataFrame::with_row_count, 2))?;
147
147
  class.define_method("_clone", method!(RbDataFrame::clone, 0))?;
148
148
  class.define_method("melt", method!(RbDataFrame::melt, 4))?;
149
- class.define_method("pivot_expr", method!(RbDataFrame::pivot_expr, 6))?;
149
+ class.define_method("pivot_expr", method!(RbDataFrame::pivot_expr, 7))?;
150
150
  class.define_method("partition_by", method!(RbDataFrame::partition_by, 2))?;
151
151
  class.define_method("shift", method!(RbDataFrame::shift, 1))?;
152
152
  class.define_method("unique", method!(RbDataFrame::unique, 3))?;
@@ -163,7 +163,7 @@ fn init() -> RbResult<()> {
163
163
  class.define_method("hmin", method!(RbDataFrame::hmin, 0))?;
164
164
  class.define_method("hsum", method!(RbDataFrame::hsum, 1))?;
165
165
  class.define_method("quantile", method!(RbDataFrame::quantile, 2))?;
166
- class.define_method("to_dummies", method!(RbDataFrame::to_dummies, 1))?;
166
+ class.define_method("to_dummies", method!(RbDataFrame::to_dummies, 2))?;
167
167
  class.define_method("null_count", method!(RbDataFrame::null_count, 0))?;
168
168
  class.define_method("apply", method!(RbDataFrame::apply, 3))?;
169
169
  class.define_method("shrink_to_fit", method!(RbDataFrame::shrink_to_fit, 0))?;
@@ -221,7 +221,7 @@ fn init() -> RbResult<()> {
221
221
  class.define_method("top_k", method!(RbExpr::top_k, 2))?;
222
222
  class.define_method("arg_max", method!(RbExpr::arg_max, 0))?;
223
223
  class.define_method("arg_min", method!(RbExpr::arg_min, 0))?;
224
- class.define_method("search_sorted", method!(RbExpr::search_sorted, 1))?;
224
+ class.define_method("search_sorted", method!(RbExpr::search_sorted, 2))?;
225
225
  class.define_method("take", method!(RbExpr::take, 1))?;
226
226
  class.define_method("sort_by", method!(RbExpr::sort_by, 2))?;
227
227
  class.define_method("backward_fill", method!(RbExpr::backward_fill, 1))?;
@@ -284,7 +284,7 @@ fn init() -> RbResult<()> {
284
284
  class.define_method("product", method!(RbExpr::product, 0))?;
285
285
  class.define_method("shrink_dtype", method!(RbExpr::shrink_dtype, 0))?;
286
286
  class.define_method("str_parse_date", method!(RbExpr::str_parse_date, 4))?;
287
- class.define_method("str_parse_datetime", method!(RbExpr::str_parse_datetime, 5))?;
287
+ class.define_method("str_parse_datetime", method!(RbExpr::str_parse_datetime, 6))?;
288
288
  class.define_method("str_parse_time", method!(RbExpr::str_parse_time, 4))?;
289
289
  class.define_method("str_strip", method!(RbExpr::str_strip, 1))?;
290
290
  class.define_method("str_rstrip", method!(RbExpr::str_rstrip, 1))?;
@@ -299,7 +299,7 @@ fn init() -> RbResult<()> {
299
299
  class.define_method("str_zfill", method!(RbExpr::str_zfill, 1))?;
300
300
  class.define_method("str_ljust", method!(RbExpr::str_ljust, 2))?;
301
301
  class.define_method("str_rjust", method!(RbExpr::str_rjust, 2))?;
302
- class.define_method("str_contains", method!(RbExpr::str_contains, 2))?;
302
+ class.define_method("str_contains", method!(RbExpr::str_contains, 3))?;
303
303
  class.define_method("str_ends_with", method!(RbExpr::str_ends_with, 1))?;
304
304
  class.define_method("str_starts_with", method!(RbExpr::str_starts_with, 1))?;
305
305
  class.define_method("str_hex_encode", method!(RbExpr::str_hex_encode, 0))?;
@@ -361,9 +361,15 @@ fn init() -> RbResult<()> {
361
361
  class.define_method("dt_offset_by", method!(RbExpr::dt_offset_by, 1))?;
362
362
  class.define_method("dt_epoch_seconds", method!(RbExpr::dt_epoch_seconds, 0))?;
363
363
  class.define_method("dt_with_time_unit", method!(RbExpr::dt_with_time_unit, 1))?;
364
- class.define_method("dt_with_time_zone", method!(RbExpr::dt_with_time_zone, 1))?;
364
+ class.define_method(
365
+ "dt_convert_time_zone",
366
+ method!(RbExpr::dt_convert_time_zone, 1),
367
+ )?;
365
368
  class.define_method("dt_cast_time_unit", method!(RbExpr::dt_cast_time_unit, 1))?;
366
- class.define_method("dt_cast_time_zone", method!(RbExpr::dt_cast_time_zone, 1))?;
369
+ class.define_method(
370
+ "dt_replace_time_zone",
371
+ method!(RbExpr::dt_replace_time_zone, 1),
372
+ )?;
367
373
  class.define_method("dt_tz_localize", method!(RbExpr::dt_tz_localize, 1))?;
368
374
  class.define_method("dt_truncate", method!(RbExpr::dt_truncate, 2))?;
369
375
  class.define_method("dt_round", method!(RbExpr::dt_round, 2))?;
@@ -418,9 +424,9 @@ fn init() -> RbResult<()> {
418
424
  class.define_method("shuffle", method!(RbExpr::shuffle, 1))?;
419
425
  class.define_method("sample_n", method!(RbExpr::sample_n, 4))?;
420
426
  class.define_method("sample_frac", method!(RbExpr::sample_frac, 4))?;
421
- class.define_method("ewm_mean", method!(RbExpr::ewm_mean, 3))?;
422
- class.define_method("ewm_std", method!(RbExpr::ewm_std, 4))?;
423
- class.define_method("ewm_var", method!(RbExpr::ewm_var, 4))?;
427
+ class.define_method("ewm_mean", method!(RbExpr::ewm_mean, 4))?;
428
+ class.define_method("ewm_std", method!(RbExpr::ewm_std, 5))?;
429
+ class.define_method("ewm_var", method!(RbExpr::ewm_var, 5))?;
424
430
  class.define_method("extend_constant", method!(RbExpr::extend_constant, 2))?;
425
431
  class.define_method("any", method!(RbExpr::any, 0))?;
426
432
  class.define_method("all", method!(RbExpr::all, 0))?;
@@ -613,7 +619,7 @@ fn init() -> RbResult<()> {
613
619
  class.define_method("_clone", method!(RbSeries::clone, 0))?;
614
620
  class.define_method("apply_lambda", method!(RbSeries::apply_lambda, 3))?;
615
621
  class.define_method("zip_with", method!(RbSeries::zip_with, 2))?;
616
- class.define_method("to_dummies", method!(RbSeries::to_dummies, 0))?;
622
+ class.define_method("to_dummies", method!(RbSeries::to_dummies, 1))?;
617
623
  class.define_method("peak_max", method!(RbSeries::peak_max, 0))?;
618
624
  class.define_method("peak_min", method!(RbSeries::peak_min, 0))?;
619
625
  class.define_method("n_unique", method!(RbSeries::n_unique, 0))?;
@@ -922,23 +928,16 @@ fn parquet_schema(rb_f: Value) -> RbResult<Value> {
922
928
  Ok(dict.into())
923
929
  }
924
930
 
925
- fn collect_all(lfs: RArray) -> RbResult<Vec<RbDataFrame>> {
926
- use polars_core::utils::rayon::prelude::*;
927
-
931
+ fn collect_all(lfs: RArray) -> RbResult<RArray> {
928
932
  let lfs = lfs
929
933
  .each()
930
934
  .map(|v| v?.try_convert::<&RbLazyFrame>())
931
935
  .collect::<RbResult<Vec<&RbLazyFrame>>>()?;
932
936
 
933
- polars_core::POOL.install(|| {
934
- lfs.par_iter()
935
- .map(|lf| {
936
- let df = lf.ldf.clone().collect()?;
937
- Ok(RbDataFrame::new(df))
938
- })
939
- .collect::<polars_core::error::PolarsResult<Vec<_>>>()
940
- .map_err(RbPolarsErr::from)
941
- })
937
+ Ok(RArray::from_iter(lfs.iter().map(|lf| {
938
+ let df = lf.ldf.clone().collect().unwrap();
939
+ RbDataFrame::new(df)
940
+ })))
942
941
  }
943
942
 
944
943
  fn rb_date_range(
@@ -949,8 +948,8 @@ fn rb_date_range(
949
948
  name: String,
950
949
  tu: Wrap<TimeUnit>,
951
950
  tz: Option<TimeZone>,
952
- ) -> RbSeries {
953
- polars::time::date_range_impl(
951
+ ) -> RbResult<RbSeries> {
952
+ let date_range = polars::time::date_range_impl(
954
953
  &name,
955
954
  start,
956
955
  stop,
@@ -959,8 +958,8 @@ fn rb_date_range(
959
958
  tu.0,
960
959
  tz.as_ref(),
961
960
  )
962
- .into_series()
963
- .into()
961
+ .map_err(RbPolarsErr::from)?;
962
+ Ok(date_range.into_series().into())
964
963
  }
965
964
 
966
965
  fn coalesce_exprs(exprs: RArray) -> RbResult<RbExpr> {
@@ -983,5 +982,5 @@ fn arg_where(condition: &RbExpr) -> RbExpr {
983
982
  }
984
983
 
985
984
  fn get_idx_type() -> Value {
986
- Wrap(IDX_DTYPE).into()
985
+ Wrap(IDX_DTYPE).into_value()
987
986
  }
@@ -1,6 +1,7 @@
1
1
  use std::any::Any;
2
2
  use std::sync::Arc;
3
3
 
4
+ use magnus::IntoValue;
4
5
  use polars_core::chunked_array::object::builder::ObjectChunkedBuilder;
5
6
  use polars_core::chunked_array::object::registry;
6
7
  use polars_core::chunked_array::object::registry::AnonymousObjectBuilder;
@@ -20,7 +21,7 @@ pub(crate) fn register_object_builder() {
20
21
 
21
22
  let object_converter = Arc::new(|av: AnyValue| {
22
23
  let object = ObjectValue {
23
- inner: Wrap(av).into(),
24
+ inner: Wrap(av).into_value(),
24
25
  };
25
26
  Box::new(object) as Box<dyn Any>
26
27
  });