polars-df 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/Cargo.lock +468 -538
  4. data/Cargo.toml +1 -0
  5. data/README.md +8 -7
  6. data/ext/polars/Cargo.toml +17 -10
  7. data/ext/polars/src/batched_csv.rs +26 -26
  8. data/ext/polars/src/conversion.rs +121 -93
  9. data/ext/polars/src/dataframe.rs +116 -71
  10. data/ext/polars/src/error.rs +0 -5
  11. data/ext/polars/src/expr/binary.rs +18 -6
  12. data/ext/polars/src/expr/datetime.rs +10 -12
  13. data/ext/polars/src/expr/general.rs +68 -284
  14. data/ext/polars/src/expr/list.rs +17 -9
  15. data/ext/polars/src/{expr.rs → expr/mod.rs} +4 -2
  16. data/ext/polars/src/expr/name.rs +44 -0
  17. data/ext/polars/src/expr/rolling.rs +196 -0
  18. data/ext/polars/src/expr/string.rs +85 -58
  19. data/ext/polars/src/file.rs +3 -3
  20. data/ext/polars/src/functions/aggregation.rs +35 -0
  21. data/ext/polars/src/functions/eager.rs +7 -31
  22. data/ext/polars/src/functions/io.rs +10 -10
  23. data/ext/polars/src/functions/lazy.rs +66 -41
  24. data/ext/polars/src/functions/meta.rs +30 -0
  25. data/ext/polars/src/functions/misc.rs +8 -0
  26. data/ext/polars/src/functions/mod.rs +5 -0
  27. data/ext/polars/src/functions/random.rs +6 -0
  28. data/ext/polars/src/functions/range.rs +46 -0
  29. data/ext/polars/src/functions/string_cache.rs +11 -0
  30. data/ext/polars/src/functions/whenthen.rs +7 -7
  31. data/ext/polars/src/lazyframe.rs +47 -42
  32. data/ext/polars/src/lib.rs +156 -72
  33. data/ext/polars/src/{apply → map}/dataframe.rs +28 -33
  34. data/ext/polars/src/{apply → map}/mod.rs +3 -3
  35. data/ext/polars/src/{apply → map}/series.rs +12 -16
  36. data/ext/polars/src/object.rs +1 -1
  37. data/ext/polars/src/rb_modules.rs +22 -7
  38. data/ext/polars/src/series/construction.rs +4 -4
  39. data/ext/polars/src/series/export.rs +2 -2
  40. data/ext/polars/src/series/set_at_idx.rs +33 -17
  41. data/ext/polars/src/series.rs +7 -27
  42. data/ext/polars/src/sql.rs +46 -0
  43. data/lib/polars/config.rb +530 -0
  44. data/lib/polars/data_frame.rb +115 -82
  45. data/lib/polars/date_time_expr.rb +13 -18
  46. data/lib/polars/date_time_name_space.rb +5 -25
  47. data/lib/polars/dynamic_group_by.rb +2 -2
  48. data/lib/polars/expr.rb +177 -94
  49. data/lib/polars/functions.rb +29 -37
  50. data/lib/polars/group_by.rb +38 -55
  51. data/lib/polars/io.rb +37 -2
  52. data/lib/polars/lazy_frame.rb +93 -66
  53. data/lib/polars/lazy_functions.rb +36 -48
  54. data/lib/polars/lazy_group_by.rb +7 -8
  55. data/lib/polars/list_expr.rb +12 -8
  56. data/lib/polars/list_name_space.rb +2 -2
  57. data/lib/polars/name_expr.rb +198 -0
  58. data/lib/polars/rolling_group_by.rb +2 -2
  59. data/lib/polars/series.rb +26 -13
  60. data/lib/polars/sql_context.rb +194 -0
  61. data/lib/polars/string_expr.rb +114 -60
  62. data/lib/polars/string_name_space.rb +19 -4
  63. data/lib/polars/utils.rb +12 -0
  64. data/lib/polars/version.rb +1 -1
  65. data/lib/polars.rb +3 -0
  66. metadata +18 -7
  67. /data/ext/polars/src/{apply → map}/lazy.rs +0 -0
@@ -1,4 +1,7 @@
1
- use magnus::{r_hash::ForEach, IntoValue, RArray, RHash, RString, Value};
1
+ use either::Either;
2
+ use magnus::{
3
+ prelude::*, r_hash::ForEach, typed_data::Obj, IntoValue, RArray, RHash, RString, Value,
4
+ };
2
5
  use polars::frame::row::{rows_to_schema_supertypes, Row};
3
6
  use polars::frame::NullStrategy;
4
7
  use polars::io::avro::AvroCompression;
@@ -11,12 +14,12 @@ use std::cell::RefCell;
11
14
  use std::io::{BufWriter, Cursor};
12
15
  use std::ops::Deref;
13
16
 
14
- use crate::apply::dataframe::{
17
+ use crate::conversion::*;
18
+ use crate::file::{get_file_like, get_mmap_bytes_reader};
19
+ use crate::map::dataframe::{
15
20
  apply_lambda_unknown, apply_lambda_with_bool_out_type, apply_lambda_with_primitive_out_type,
16
21
  apply_lambda_with_utf8_out_type,
17
22
  };
18
- use crate::conversion::*;
19
- use crate::file::{get_file_like, get_mmap_bytes_reader};
20
23
  use crate::rb_modules;
21
24
  use crate::series::{to_rbseries_collection, to_series_collection};
22
25
  use crate::{RbExpr, RbLazyFrame, RbPolarsErr, RbResult, RbSeries};
@@ -53,7 +56,7 @@ impl RbDataFrame {
53
56
  // replace inferred nulls with boolean
54
57
  let fields = schema.iter_fields().map(|mut fld| match fld.data_type() {
55
58
  DataType::Null => {
56
- fld.coerce(DataType::Boolean);
59
+ // fld.coerce(DataType::Boolean);
57
60
  fld
58
61
  }
59
62
  DataType::Decimal(_, _) => {
@@ -86,7 +89,7 @@ impl RbDataFrame {
86
89
  pub fn init(columns: RArray) -> RbResult<Self> {
87
90
  let mut cols = Vec::new();
88
91
  for i in columns.each() {
89
- cols.push(i?.try_convert::<&RbSeries>()?.series.borrow().clone());
92
+ cols.push(<&RbSeries>::try_convert(i?)?.series.borrow().clone());
90
93
  }
91
94
  let df = DataFrame::new(cols).map_err(RbPolarsErr::from)?;
92
95
  Ok(RbDataFrame::new(df))
@@ -99,32 +102,32 @@ impl RbDataFrame {
99
102
  pub fn read_csv(arguments: &[Value]) -> RbResult<Self> {
100
103
  // start arguments
101
104
  // this pattern is needed for more than 16
102
- let rb_f: Value = arguments[0].try_convert()?;
103
- let infer_schema_length: Option<usize> = arguments[1].try_convert()?;
104
- let chunk_size: usize = arguments[2].try_convert()?;
105
- let has_header: bool = arguments[3].try_convert()?;
106
- let ignore_errors: bool = arguments[4].try_convert()?;
107
- let n_rows: Option<usize> = arguments[5].try_convert()?;
108
- let skip_rows: usize = arguments[6].try_convert()?;
109
- let projection: Option<Vec<usize>> = arguments[7].try_convert()?;
110
- let sep: String = arguments[8].try_convert()?;
111
- let rechunk: bool = arguments[9].try_convert()?;
112
- let columns: Option<Vec<String>> = arguments[10].try_convert()?;
113
- let encoding: Wrap<CsvEncoding> = arguments[11].try_convert()?;
114
- let n_threads: Option<usize> = arguments[12].try_convert()?;
115
- let path: Option<String> = arguments[13].try_convert()?;
116
- let overwrite_dtype: Option<Vec<(String, Wrap<DataType>)>> = arguments[14].try_convert()?;
105
+ let rb_f = arguments[0];
106
+ let infer_schema_length = Option::<usize>::try_convert(arguments[1])?;
107
+ let chunk_size = usize::try_convert(arguments[2])?;
108
+ let has_header = bool::try_convert(arguments[3])?;
109
+ let ignore_errors = bool::try_convert(arguments[4])?;
110
+ let n_rows = Option::<usize>::try_convert(arguments[5])?;
111
+ let skip_rows = usize::try_convert(arguments[6])?;
112
+ let projection = Option::<Vec<usize>>::try_convert(arguments[7])?;
113
+ let separator = String::try_convert(arguments[8])?;
114
+ let rechunk = bool::try_convert(arguments[9])?;
115
+ let columns = Option::<Vec<String>>::try_convert(arguments[10])?;
116
+ let encoding = Wrap::<CsvEncoding>::try_convert(arguments[11])?;
117
+ let n_threads = Option::<usize>::try_convert(arguments[12])?;
118
+ let path = Option::<String>::try_convert(arguments[13])?;
119
+ let overwrite_dtype = Option::<Vec<(String, Wrap<DataType>)>>::try_convert(arguments[14])?;
117
120
  // TODO fix
118
- let overwrite_dtype_slice: Option<Vec<Wrap<DataType>>> = None; // arguments[15].try_convert()?;
119
- let low_memory: bool = arguments[16].try_convert()?;
120
- let comment_char: Option<String> = arguments[17].try_convert()?;
121
- let quote_char: Option<String> = arguments[18].try_convert()?;
122
- let null_values: Option<Wrap<NullValues>> = arguments[19].try_convert()?;
123
- let try_parse_dates: bool = arguments[20].try_convert()?;
124
- let skip_rows_after_header: usize = arguments[21].try_convert()?;
125
- let row_count: Option<(String, IdxSize)> = arguments[22].try_convert()?;
126
- let sample_size: usize = arguments[23].try_convert()?;
127
- let eol_char: String = arguments[24].try_convert()?;
121
+ let overwrite_dtype_slice = Option::<Vec<Wrap<DataType>>>::None; // Option::<Vec<Wrap<DataType>>>::try_convert(arguments[15])?;
122
+ let low_memory = bool::try_convert(arguments[16])?;
123
+ let comment_char = Option::<String>::try_convert(arguments[17])?;
124
+ let quote_char = Option::<String>::try_convert(arguments[18])?;
125
+ let null_values = Option::<Wrap<NullValues>>::try_convert(arguments[19])?;
126
+ let try_parse_dates = bool::try_convert(arguments[20])?;
127
+ let skip_rows_after_header = usize::try_convert(arguments[21])?;
128
+ let row_count = Option::<(String, IdxSize)>::try_convert(arguments[22])?;
129
+ let sample_size = usize::try_convert(arguments[23])?;
130
+ let eol_char = String::try_convert(arguments[24])?;
128
131
  // end arguments
129
132
 
130
133
  let null_values = null_values.map(|w| w.0);
@@ -165,7 +168,7 @@ impl RbDataFrame {
165
168
  .infer_schema(infer_schema_length)
166
169
  .has_header(has_header)
167
170
  .with_n_rows(n_rows)
168
- .with_delimiter(sep.as_bytes()[0])
171
+ .with_separator(separator.as_bytes()[0])
169
172
  .with_skip_rows(skip_rows)
170
173
  .with_ignore_errors(ignore_errors)
171
174
  .with_projection(projection)
@@ -265,7 +268,7 @@ impl RbDataFrame {
265
268
  ) -> RbResult<()> {
266
269
  use polars::io::avro::AvroWriter;
267
270
 
268
- if let Ok(s) = rb_f.try_convert::<String>() {
271
+ if let Ok(s) = String::try_convert(rb_f) {
269
272
  let f = std::fs::File::create(s).unwrap();
270
273
  AvroWriter::new(f)
271
274
  .with_compression(compression.0)
@@ -341,6 +344,27 @@ impl RbDataFrame {
341
344
  Ok(())
342
345
  }
343
346
 
347
+ pub fn read_rows(
348
+ rb_rows: RArray,
349
+ infer_schema_length: Option<usize>,
350
+ schema_overwrite: Option<Wrap<Schema>>,
351
+ ) -> RbResult<Self> {
352
+ let mut rows = Vec::with_capacity(rb_rows.len());
353
+ for v in rb_rows.each() {
354
+ let rb_row = RArray::try_convert(v?)?;
355
+ let mut row = Vec::with_capacity(rb_row.len());
356
+ for val in rb_row.each() {
357
+ row.push(Wrap::<AnyValue>::try_convert(val?)?.0);
358
+ }
359
+ rows.push(Row(row));
360
+ }
361
+ Self::finish_from_rows(
362
+ rows,
363
+ infer_schema_length,
364
+ schema_overwrite.map(|wrap| wrap.0),
365
+ )
366
+ }
367
+
344
368
  pub fn read_hashes(
345
369
  dicts: Value,
346
370
  infer_schema_length: Option<usize>,
@@ -395,9 +419,9 @@ impl RbDataFrame {
395
419
  pub fn write_csv(
396
420
  &self,
397
421
  rb_f: Value,
398
- has_header: bool,
399
- sep: u8,
400
- quote: u8,
422
+ include_header: bool,
423
+ separator: u8,
424
+ quote_char: u8,
401
425
  batch_size: usize,
402
426
  datetime_format: Option<String>,
403
427
  date_format: Option<String>,
@@ -407,13 +431,13 @@ impl RbDataFrame {
407
431
  ) -> RbResult<()> {
408
432
  let null = null_value.unwrap_or_default();
409
433
 
410
- if let Ok(s) = rb_f.try_convert::<String>() {
434
+ if let Ok(s) = String::try_convert(rb_f) {
411
435
  let f = std::fs::File::create(s).unwrap();
412
436
  // no need for a buffered writer, because the csv writer does internal buffering
413
437
  CsvWriter::new(f)
414
- .has_header(has_header)
415
- .with_delimiter(sep)
416
- .with_quoting_char(quote)
438
+ .include_header(include_header)
439
+ .with_separator(separator)
440
+ .with_quote_char(quote_char)
417
441
  .with_batch_size(batch_size)
418
442
  .with_datetime_format(datetime_format)
419
443
  .with_date_format(date_format)
@@ -425,9 +449,9 @@ impl RbDataFrame {
425
449
  } else {
426
450
  let mut buf = Cursor::new(Vec::new());
427
451
  CsvWriter::new(&mut buf)
428
- .has_header(has_header)
429
- .with_delimiter(sep)
430
- .with_quoting_char(quote)
452
+ .include_header(include_header)
453
+ .with_separator(separator)
454
+ .with_quote_char(quote_char)
431
455
  .with_batch_size(batch_size)
432
456
  .with_datetime_format(datetime_format)
433
457
  .with_date_format(date_format)
@@ -449,7 +473,7 @@ impl RbDataFrame {
449
473
  rb_f: Value,
450
474
  compression: Wrap<Option<IpcCompression>>,
451
475
  ) -> RbResult<()> {
452
- if let Ok(s) = rb_f.try_convert::<String>() {
476
+ if let Ok(s) = String::try_convert(rb_f) {
453
477
  let f = std::fs::File::create(s).unwrap();
454
478
  IpcWriter::new(f)
455
479
  .with_compression(compression.0)
@@ -487,7 +511,7 @@ impl RbDataFrame {
487
511
  _ => Wrap(s.get(idx).unwrap()).into_value(),
488
512
  }),
489
513
  )
490
- .into()
514
+ .as_value()
491
515
  }
492
516
 
493
517
  pub fn row_tuples(&self) -> Value {
@@ -507,7 +531,7 @@ impl RbDataFrame {
507
531
  }),
508
532
  )
509
533
  }))
510
- .into()
534
+ .as_value()
511
535
  }
512
536
 
513
537
  pub fn to_numo(&self) -> Option<Value> {
@@ -537,7 +561,7 @@ impl RbDataFrame {
537
561
  ) -> RbResult<()> {
538
562
  let compression = parse_parquet_compression(&compression, compression_level)?;
539
563
 
540
- if let Ok(s) = rb_f.try_convert::<String>() {
564
+ if let Ok(s) = String::try_convert(rb_f) {
541
565
  let f = std::fs::File::create(s).unwrap();
542
566
  ParquetWriter::new(f)
543
567
  .with_compression(compression)
@@ -604,7 +628,7 @@ impl RbDataFrame {
604
628
 
605
629
  pub fn sample_n(
606
630
  &self,
607
- n: usize,
631
+ n: &RbSeries,
608
632
  with_replacement: bool,
609
633
  shuffle: bool,
610
634
  seed: Option<u64>,
@@ -612,14 +636,14 @@ impl RbDataFrame {
612
636
  let df = self
613
637
  .df
614
638
  .borrow()
615
- .sample_n(n, with_replacement, shuffle, seed)
639
+ .sample_n(&n.series.borrow(), with_replacement, shuffle, seed)
616
640
  .map_err(RbPolarsErr::from)?;
617
641
  Ok(df.into())
618
642
  }
619
643
 
620
644
  pub fn sample_frac(
621
645
  &self,
622
- frac: f64,
646
+ frac: &RbSeries,
623
647
  with_replacement: bool,
624
648
  shuffle: bool,
625
649
  seed: Option<u64>,
@@ -627,7 +651,7 @@ impl RbDataFrame {
627
651
  let df = self
628
652
  .df
629
653
  .borrow()
630
- .sample_frac(frac, with_replacement, shuffle, seed)
654
+ .sample_frac(&frac.series.borrow(), with_replacement, shuffle, seed)
631
655
  .map_err(RbPolarsErr::from)?;
632
656
  Ok(df.into())
633
657
  }
@@ -970,30 +994,48 @@ impl RbDataFrame {
970
994
  self.df.borrow().median().into()
971
995
  }
972
996
 
973
- pub fn hmean(&self, null_strategy: Wrap<NullStrategy>) -> RbResult<Option<RbSeries>> {
997
+ pub fn max_horizontal(&self) -> RbResult<Option<RbSeries>> {
974
998
  let s = self
975
999
  .df
976
1000
  .borrow()
977
- .hmean(null_strategy.0)
1001
+ .max_horizontal()
978
1002
  .map_err(RbPolarsErr::from)?;
979
1003
  Ok(s.map(|s| s.into()))
980
1004
  }
981
1005
 
982
- pub fn hmax(&self) -> RbResult<Option<RbSeries>> {
983
- let s = self.df.borrow().hmax().map_err(RbPolarsErr::from)?;
1006
+ pub fn min_horizontal(&self) -> RbResult<Option<RbSeries>> {
1007
+ let s = self
1008
+ .df
1009
+ .borrow()
1010
+ .min_horizontal()
1011
+ .map_err(RbPolarsErr::from)?;
984
1012
  Ok(s.map(|s| s.into()))
985
1013
  }
986
1014
 
987
- pub fn hmin(&self) -> RbResult<Option<RbSeries>> {
988
- let s = self.df.borrow().hmin().map_err(RbPolarsErr::from)?;
1015
+ pub fn sum_horizontal(&self, ignore_nulls: bool) -> RbResult<Option<RbSeries>> {
1016
+ let null_strategy = if ignore_nulls {
1017
+ NullStrategy::Ignore
1018
+ } else {
1019
+ NullStrategy::Propagate
1020
+ };
1021
+ let s = self
1022
+ .df
1023
+ .borrow()
1024
+ .sum_horizontal(null_strategy)
1025
+ .map_err(RbPolarsErr::from)?;
989
1026
  Ok(s.map(|s| s.into()))
990
1027
  }
991
1028
 
992
- pub fn hsum(&self, null_strategy: Wrap<NullStrategy>) -> RbResult<Option<RbSeries>> {
1029
+ pub fn mean_horizontal(&self, ignore_nulls: bool) -> RbResult<Option<RbSeries>> {
1030
+ let null_strategy = if ignore_nulls {
1031
+ NullStrategy::Ignore
1032
+ } else {
1033
+ NullStrategy::Propagate
1034
+ };
993
1035
  let s = self
994
1036
  .df
995
1037
  .borrow()
996
- .hsum(null_strategy.0)
1038
+ .mean_horizontal(null_strategy)
997
1039
  .map_err(RbPolarsErr::from)?;
998
1040
  Ok(s.map(|s| s.into()))
999
1041
  }
@@ -1088,7 +1130,7 @@ impl RbDataFrame {
1088
1130
  _ => return apply_lambda_unknown(df, lambda, inference_size),
1089
1131
  };
1090
1132
 
1091
- Ok((RbSeries::from(out).into(), false))
1133
+ Ok((Obj::wrap(RbSeries::from(out)).as_value(), false))
1092
1134
  }
1093
1135
 
1094
1136
  pub fn shrink_to_fit(&self) {
@@ -1105,17 +1147,20 @@ impl RbDataFrame {
1105
1147
  Ok(hash.into_series().into())
1106
1148
  }
1107
1149
 
1108
- pub fn transpose(&self, include_header: bool, names: String) -> RbResult<Self> {
1109
- let mut df = self.df.borrow().transpose().map_err(RbPolarsErr::from)?;
1110
- if include_header {
1111
- let s = Utf8Chunked::from_iter_values(
1112
- &names,
1113
- self.df.borrow().get_columns().iter().map(|s| s.name()),
1114
- )
1115
- .into_series();
1116
- df.insert_at_idx(0, s).unwrap();
1117
- }
1118
- Ok(df.into())
1150
+ pub fn transpose(&self, keep_names_as: Option<String>, column_names: Value) -> RbResult<Self> {
1151
+ let new_col_names = if let Ok(name) = <Vec<String>>::try_convert(column_names) {
1152
+ Some(Either::Right(name))
1153
+ } else if let Ok(name) = String::try_convert(column_names) {
1154
+ Some(Either::Left(name))
1155
+ } else {
1156
+ None
1157
+ };
1158
+ Ok(self
1159
+ .df
1160
+ .borrow()
1161
+ .transpose(keep_names_as.as_deref(), new_col_names)
1162
+ .map_err(RbPolarsErr::from)?
1163
+ .into())
1119
1164
  }
1120
1165
 
1121
1166
  pub fn upsample(
@@ -1,6 +1,5 @@
1
1
  use magnus::exception;
2
2
  use magnus::Error;
3
- use polars::error::ArrowError;
4
3
  use polars::prelude::PolarsError;
5
4
 
6
5
  pub struct RbPolarsErr {}
@@ -11,10 +10,6 @@ impl RbPolarsErr {
11
10
  Error::new(exception::runtime_error(), e.to_string())
12
11
  }
13
12
 
14
- pub fn arrow(e: ArrowError) -> Error {
15
- Error::new(exception::runtime_error(), e.to_string())
16
- }
17
-
18
13
  pub fn io(e: std::io::Error) -> Error {
19
14
  Error::new(exception::runtime_error(), e.to_string())
20
15
  }
@@ -3,16 +3,28 @@ use polars::prelude::*;
3
3
  use crate::RbExpr;
4
4
 
5
5
  impl RbExpr {
6
- pub fn bin_contains(&self, lit: Vec<u8>) -> Self {
7
- self.inner.clone().binary().contains_literal(lit).into()
6
+ pub fn bin_contains(&self, lit: &RbExpr) -> Self {
7
+ self.inner
8
+ .clone()
9
+ .binary()
10
+ .contains_literal(lit.inner.clone())
11
+ .into()
8
12
  }
9
13
 
10
- pub fn bin_ends_with(&self, sub: Vec<u8>) -> Self {
11
- self.inner.clone().binary().ends_with(sub).into()
14
+ pub fn bin_ends_with(&self, sub: &RbExpr) -> Self {
15
+ self.inner
16
+ .clone()
17
+ .binary()
18
+ .ends_with(sub.inner.clone())
19
+ .into()
12
20
  }
13
21
 
14
- pub fn bin_starts_with(&self, sub: Vec<u8>) -> Self {
15
- self.inner.clone().binary().starts_with(sub).into()
22
+ pub fn bin_starts_with(&self, sub: &RbExpr) -> Self {
23
+ self.inner
24
+ .clone()
25
+ .binary()
26
+ .starts_with(sub.inner.clone())
27
+ .into()
16
28
  }
17
29
 
18
30
  pub fn bin_hex_decode(&self, strict: bool) -> Self {
@@ -8,9 +8,8 @@ impl RbExpr {
8
8
  self.inner.clone().dt().to_string(&format).into()
9
9
  }
10
10
 
11
- pub fn dt_offset_by(&self, by: String) -> Self {
12
- let by = Duration::parse(&by);
13
- self.inner.clone().dt().offset_by(by).into()
11
+ pub fn dt_offset_by(&self, by: &RbExpr) -> Self {
12
+ self.inner.clone().dt().offset_by(by.inner.clone()).into()
14
13
  }
15
14
 
16
15
  pub fn dt_epoch_seconds(&self) -> Self {
@@ -38,21 +37,20 @@ impl RbExpr {
38
37
  self.inner.clone().dt().cast_time_unit(tu.0).into()
39
38
  }
40
39
 
41
- pub fn dt_replace_time_zone(&self, tz: Option<String>, use_earliest: Option<bool>) -> Self {
40
+ pub fn dt_replace_time_zone(&self, time_zone: Option<String>, ambiguous: &Self) -> Self {
42
41
  self.inner
43
42
  .clone()
44
43
  .dt()
45
- .replace_time_zone(tz, use_earliest)
44
+ .replace_time_zone(time_zone, ambiguous.inner.clone())
46
45
  .into()
47
46
  }
48
47
 
49
- #[allow(deprecated)]
50
- pub fn dt_tz_localize(&self, tz: String) -> Self {
51
- self.inner.clone().dt().tz_localize(tz).into()
52
- }
53
-
54
- pub fn dt_truncate(&self, every: String, offset: String) -> Self {
55
- self.inner.clone().dt().truncate(&every, &offset).into()
48
+ pub fn dt_truncate(&self, every: &Self, offset: String) -> Self {
49
+ self.inner
50
+ .clone()
51
+ .dt()
52
+ .truncate(every.inner.clone(), offset)
53
+ .into()
56
54
  }
57
55
 
58
56
  pub fn dt_month_start(&self) -> Self {