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,4 +1,3 @@
1
- mod apply;
2
1
  mod batched_csv;
3
2
  mod conversion;
4
3
  mod dataframe;
@@ -8,23 +7,26 @@ mod file;
8
7
  mod functions;
9
8
  mod lazyframe;
10
9
  mod lazygroupby;
10
+ mod map;
11
11
  mod object;
12
12
  mod prelude;
13
13
  pub(crate) mod rb_modules;
14
14
  mod series;
15
+ mod sql;
15
16
  mod utils;
16
17
 
17
18
  use batched_csv::RbBatchedCsv;
18
19
  use conversion::*;
19
20
  use dataframe::RbDataFrame;
20
- use error::{RbPolarsErr, RbValueError};
21
+ use error::{RbPolarsErr, RbTypeError, RbValueError};
21
22
  use expr::rb_exprs_to_exprs;
22
23
  use expr::RbExpr;
23
- use functions::whenthen::{RbWhen, RbWhenThen};
24
+ use functions::whenthen::{RbThen, RbWhen};
24
25
  use lazyframe::RbLazyFrame;
25
26
  use lazygroupby::RbLazyGroupBy;
26
- use magnus::{define_module, function, method, prelude::*, Error};
27
+ use magnus::{define_module, function, method, prelude::*, Error, Ruby};
27
28
  use series::RbSeries;
29
+ use sql::RbSQLContext;
28
30
 
29
31
  #[cfg(target_os = "linux")]
30
32
  use jemallocator::Jemalloc;
@@ -43,15 +45,19 @@ static GLOBAL: MiMalloc = MiMalloc;
43
45
  type RbResult<T> = Result<T, Error>;
44
46
 
45
47
  #[magnus::init]
46
- fn init() -> RbResult<()> {
48
+ fn init(ruby: &Ruby) -> RbResult<()> {
47
49
  let module = define_module("Polars")?;
48
50
  module.define_singleton_method(
49
51
  "_dtype_cols",
50
52
  function!(crate::functions::lazy::dtype_cols2, 1),
51
53
  )?;
54
+ module.define_singleton_method(
55
+ "_concat_lf_diagonal",
56
+ function!(crate::functions::lazy::concat_lf_diagonal, 4),
57
+ )?;
52
58
  module.define_singleton_method(
53
59
  "_rb_duration",
54
- function!(crate::functions::lazy::duration, 8),
60
+ function!(crate::functions::lazy::duration, 9),
55
61
  )?;
56
62
  module.define_singleton_method(
57
63
  "_concat_df",
@@ -59,15 +65,15 @@ fn init() -> RbResult<()> {
59
65
  )?;
60
66
  module.define_singleton_method(
61
67
  "_concat_lf",
62
- function!(crate::functions::lazy::concat_lf, 3),
68
+ function!(crate::functions::lazy::concat_lf, 4),
63
69
  )?;
64
70
  module.define_singleton_method(
65
- "_diag_concat_df",
66
- function!(crate::functions::eager::diag_concat_df, 1),
71
+ "_concat_df_diagonal",
72
+ function!(crate::functions::eager::concat_df_diagonal, 1),
67
73
  )?;
68
74
  module.define_singleton_method(
69
- "_hor_concat_df",
70
- function!(crate::functions::eager::hor_concat_df, 1),
75
+ "_concat_df_horizontal",
76
+ function!(crate::functions::eager::concat_df_horizontal, 1),
71
77
  )?;
72
78
  module.define_singleton_method(
73
79
  "_concat_series",
@@ -87,15 +93,35 @@ fn init() -> RbResult<()> {
87
93
  )?;
88
94
  module.define_singleton_method(
89
95
  "_rb_date_range",
90
- function!(crate::functions::eager::date_range, 7),
96
+ function!(crate::functions::range::date_range, 6),
91
97
  )?;
92
98
  module.define_singleton_method(
93
99
  "_coalesce_exprs",
94
100
  function!(crate::functions::lazy::coalesce, 1),
95
101
  )?;
96
102
  module.define_singleton_method(
97
- "_sum_exprs",
98
- function!(crate::functions::lazy::sum_exprs, 1),
103
+ "_all_horizontal",
104
+ function!(crate::functions::aggregation::all_horizontal, 1),
105
+ )?;
106
+ module.define_singleton_method(
107
+ "_any_horizontal",
108
+ function!(crate::functions::aggregation::any_horizontal, 1),
109
+ )?;
110
+ module.define_singleton_method(
111
+ "_max_horizontal",
112
+ function!(crate::functions::aggregation::max_horizontal, 1),
113
+ )?;
114
+ module.define_singleton_method(
115
+ "_min_horizontal",
116
+ function!(crate::functions::aggregation::min_horizontal, 1),
117
+ )?;
118
+ module.define_singleton_method(
119
+ "_sum_horizontal",
120
+ function!(crate::functions::aggregation::sum_horizontal, 1),
121
+ )?;
122
+ module.define_singleton_method(
123
+ "_dtype_str_repr",
124
+ function!(crate::functions::misc::dtype_str_repr, 1),
99
125
  )?;
100
126
  module.define_singleton_method(
101
127
  "_as_struct",
@@ -109,17 +135,46 @@ fn init() -> RbResult<()> {
109
135
  "_get_idx_type",
110
136
  function!(crate::functions::meta::get_idx_type, 0),
111
137
  )?;
138
+ module.define_singleton_method(
139
+ "_threadpool_size",
140
+ function!(crate::functions::meta::threadpool_size, 0),
141
+ )?;
142
+ module.define_singleton_method(
143
+ "_enable_string_cache",
144
+ function!(crate::functions::string_cache::enable_string_cache, 0),
145
+ )?;
146
+ module.define_singleton_method(
147
+ "_disable_string_cache",
148
+ function!(crate::functions::string_cache::disable_string_cache, 0),
149
+ )?;
150
+ module.define_singleton_method(
151
+ "_using_string_cache",
152
+ function!(crate::functions::string_cache::using_string_cache, 0),
153
+ )?;
154
+ module.define_singleton_method(
155
+ "_set_float_fmt",
156
+ function!(crate::functions::meta::set_float_fmt, 1),
157
+ )?;
158
+ module.define_singleton_method(
159
+ "_get_float_fmt",
160
+ function!(crate::functions::meta::get_float_fmt, 0),
161
+ )?;
162
+ module.define_singleton_method(
163
+ "_set_random_seed",
164
+ function!(crate::functions::random::set_random_seed, 1),
165
+ )?;
112
166
 
113
- let class = module.define_class("RbBatchedCsv", Default::default())?;
167
+ let class = module.define_class("RbBatchedCsv", ruby.class_object())?;
114
168
  class.define_singleton_method("new", function!(RbBatchedCsv::new, -1))?;
115
169
  class.define_method("next_batches", method!(RbBatchedCsv::next_batches, 1))?;
116
170
 
117
- let class = module.define_class("RbDataFrame", Default::default())?;
171
+ let class = module.define_class("RbDataFrame", ruby.class_object())?;
118
172
  class.define_singleton_method("new", function!(RbDataFrame::init, 1))?;
119
173
  class.define_singleton_method("read_csv", function!(RbDataFrame::read_csv, -1))?;
120
174
  class.define_singleton_method("read_parquet", function!(RbDataFrame::read_parquet, 9))?;
121
175
  class.define_singleton_method("read_ipc", function!(RbDataFrame::read_ipc, 6))?;
122
176
  class.define_singleton_method("read_avro", function!(RbDataFrame::read_avro, 4))?;
177
+ class.define_singleton_method("read_rows", function!(RbDataFrame::read_rows, 3))?;
123
178
  class.define_singleton_method("read_hashes", function!(RbDataFrame::read_hashes, 3))?;
124
179
  class.define_singleton_method("read_hash", function!(RbDataFrame::read_hash, 1))?;
125
180
  class.define_singleton_method("read_json", function!(RbDataFrame::read_json, 1))?;
@@ -179,7 +234,6 @@ fn init() -> RbResult<()> {
179
234
  "take_with_series",
180
235
  method!(RbDataFrame::take_with_series, 1),
181
236
  )?;
182
- class.define_method("sort", method!(RbDataFrame::sort, 3))?;
183
237
  class.define_method("replace", method!(RbDataFrame::replace, 2))?;
184
238
  class.define_method("replace_at_idx", method!(RbDataFrame::replace_at_idx, 2))?;
185
239
  class.define_method("insert_at_idx", method!(RbDataFrame::insert_at_idx, 2))?;
@@ -193,7 +247,7 @@ fn init() -> RbResult<()> {
193
247
  class.define_method("_clone", method!(RbDataFrame::clone, 0))?;
194
248
  class.define_method("melt", method!(RbDataFrame::melt, 4))?;
195
249
  class.define_method("pivot_expr", method!(RbDataFrame::pivot_expr, 7))?;
196
- class.define_method("partition_by", method!(RbDataFrame::partition_by, 2))?;
250
+ class.define_method("partition_by", method!(RbDataFrame::partition_by, 3))?;
197
251
  class.define_method("shift", method!(RbDataFrame::shift, 1))?;
198
252
  class.define_method("lazy", method!(RbDataFrame::lazy, 0))?;
199
253
  class.define_method("max", method!(RbDataFrame::max, 0))?;
@@ -203,12 +257,12 @@ fn init() -> RbResult<()> {
203
257
  class.define_method("std", method!(RbDataFrame::std, 1))?;
204
258
  class.define_method("var", method!(RbDataFrame::var, 1))?;
205
259
  class.define_method("median", method!(RbDataFrame::median, 0))?;
206
- class.define_method("hmean", method!(RbDataFrame::hmean, 1))?;
207
- class.define_method("hmax", method!(RbDataFrame::hmax, 0))?;
208
- class.define_method("hmin", method!(RbDataFrame::hmin, 0))?;
209
- class.define_method("hsum", method!(RbDataFrame::hsum, 1))?;
260
+ class.define_method("mean_horizontal", method!(RbDataFrame::mean_horizontal, 1))?;
261
+ class.define_method("max_horizontal", method!(RbDataFrame::max_horizontal, 0))?;
262
+ class.define_method("min_horizontal", method!(RbDataFrame::min_horizontal, 0))?;
263
+ class.define_method("sum_horizontal", method!(RbDataFrame::sum_horizontal, 1))?;
210
264
  class.define_method("quantile", method!(RbDataFrame::quantile, 2))?;
211
- class.define_method("to_dummies", method!(RbDataFrame::to_dummies, 2))?;
265
+ class.define_method("to_dummies", method!(RbDataFrame::to_dummies, 3))?;
212
266
  class.define_method("null_count", method!(RbDataFrame::null_count, 0))?;
213
267
  class.define_method("apply", method!(RbDataFrame::apply, 3))?;
214
268
  class.define_method("shrink_to_fit", method!(RbDataFrame::shrink_to_fit, 0))?;
@@ -218,7 +272,7 @@ fn init() -> RbResult<()> {
218
272
  class.define_method("to_struct", method!(RbDataFrame::to_struct, 1))?;
219
273
  class.define_method("unnest", method!(RbDataFrame::unnest, 1))?;
220
274
 
221
- let class = module.define_class("RbExpr", Default::default())?;
275
+ let class = module.define_class("RbExpr", ruby.class_object())?;
222
276
  class.define_method("+", method!(RbExpr::add, 1))?;
223
277
  class.define_method("-", method!(RbExpr::sub, 1))?;
224
278
  class.define_method("*", method!(RbExpr::mul, 1))?;
@@ -265,15 +319,16 @@ fn init() -> RbResult<()> {
265
319
  class.define_method("arg_sort", method!(RbExpr::arg_sort, 2))?;
266
320
  class.define_method("top_k", method!(RbExpr::top_k, 1))?;
267
321
  class.define_method("bottom_k", method!(RbExpr::bottom_k, 1))?;
322
+ class.define_method("peak_min", method!(RbExpr::peak_min, 0))?;
323
+ class.define_method("peak_max", method!(RbExpr::peak_max, 0))?;
268
324
  class.define_method("arg_max", method!(RbExpr::arg_max, 0))?;
269
325
  class.define_method("arg_min", method!(RbExpr::arg_min, 0))?;
270
326
  class.define_method("search_sorted", method!(RbExpr::search_sorted, 2))?;
271
- class.define_method("take", method!(RbExpr::take, 1))?;
327
+ class.define_method("gather", method!(RbExpr::gather, 1))?;
272
328
  class.define_method("sort_by", method!(RbExpr::sort_by, 2))?;
273
329
  class.define_method("backward_fill", method!(RbExpr::backward_fill, 1))?;
274
330
  class.define_method("forward_fill", method!(RbExpr::forward_fill, 1))?;
275
- class.define_method("shift", method!(RbExpr::shift, 1))?;
276
- class.define_method("shift_and_fill", method!(RbExpr::shift_and_fill, 2))?;
331
+ class.define_method("shift", method!(RbExpr::shift, 2))?;
277
332
  class.define_method("fill_null", method!(RbExpr::fill_null, 1))?;
278
333
  class.define_method(
279
334
  "fill_null_with_strategy",
@@ -287,10 +342,11 @@ fn init() -> RbResult<()> {
287
342
  class.define_method("std", method!(RbExpr::std, 1))?;
288
343
  class.define_method("var", method!(RbExpr::var, 1))?;
289
344
  class.define_method("is_unique", method!(RbExpr::is_unique, 0))?;
290
- class.define_method("approx_unique", method!(RbExpr::approx_unique, 0))?;
291
- class.define_method("is_first", method!(RbExpr::is_first, 0))?;
345
+ class.define_method("approx_n_unique", method!(RbExpr::approx_n_unique, 0))?;
346
+ class.define_method("is_first_distinct", method!(RbExpr::is_first_distinct, 0))?;
347
+ class.define_method("is_last_distinct", method!(RbExpr::is_last_distinct, 0))?;
292
348
  class.define_method("explode", method!(RbExpr::explode, 0))?;
293
- class.define_method("take_every", method!(RbExpr::take_every, 1))?;
349
+ class.define_method("gather_every", method!(RbExpr::gather_every, 1))?;
294
350
  class.define_method("tail", method!(RbExpr::tail, 1))?;
295
351
  class.define_method("head", method!(RbExpr::head, 1))?;
296
352
  class.define_method("slice", method!(RbExpr::slice, 2))?;
@@ -300,8 +356,6 @@ fn init() -> RbResult<()> {
300
356
  class.define_method("floor", method!(RbExpr::floor, 0))?;
301
357
  class.define_method("ceil", method!(RbExpr::ceil, 0))?;
302
358
  class.define_method("clip", method!(RbExpr::clip, 2))?;
303
- class.define_method("clip_min", method!(RbExpr::clip_min, 1))?;
304
- class.define_method("clip_max", method!(RbExpr::clip_max, 1))?;
305
359
  class.define_method("abs", method!(RbExpr::abs, 0))?;
306
360
  class.define_method("sin", method!(RbExpr::sin, 0))?;
307
361
  class.define_method("cos", method!(RbExpr::cos, 0))?;
@@ -324,31 +378,43 @@ fn init() -> RbResult<()> {
324
378
  class.define_method("is_in", method!(RbExpr::is_in, 1))?;
325
379
  class.define_method("repeat_by", method!(RbExpr::repeat_by, 1))?;
326
380
  class.define_method("pow", method!(RbExpr::pow, 1))?;
327
- class.define_method("cumsum", method!(RbExpr::cumsum, 1))?;
328
- class.define_method("cummax", method!(RbExpr::cummax, 1))?;
329
- class.define_method("cummin", method!(RbExpr::cummin, 1))?;
330
- class.define_method("cumprod", method!(RbExpr::cumprod, 1))?;
381
+ class.define_method("cum_sum", method!(RbExpr::cum_sum, 1))?;
382
+ class.define_method("cum_max", method!(RbExpr::cum_max, 1))?;
383
+ class.define_method("cum_min", method!(RbExpr::cum_min, 1))?;
384
+ class.define_method("cum_prod", method!(RbExpr::cum_prod, 1))?;
331
385
  class.define_method("product", method!(RbExpr::product, 0))?;
332
386
  class.define_method("shrink_dtype", method!(RbExpr::shrink_dtype, 0))?;
333
- class.define_method("str_parse_date", method!(RbExpr::str_to_date, 4))?;
334
- class.define_method("str_parse_datetime", method!(RbExpr::str_to_datetime, 8))?;
335
- class.define_method("str_parse_time", method!(RbExpr::str_to_time, 3))?;
336
- class.define_method("str_strip", method!(RbExpr::str_strip, 1))?;
337
- class.define_method("str_rstrip", method!(RbExpr::str_rstrip, 1))?;
338
- class.define_method("str_lstrip", method!(RbExpr::str_lstrip, 1))?;
387
+ class.define_method("str_to_date", method!(RbExpr::str_to_date, 4))?;
388
+ class.define_method("str_to_datetime", method!(RbExpr::str_to_datetime, 7))?;
389
+ class.define_method("str_to_time", method!(RbExpr::str_to_time, 3))?;
390
+ class.define_method("str_strip_chars", method!(RbExpr::str_strip_chars, 1))?;
391
+ class.define_method(
392
+ "str_strip_chars_start",
393
+ method!(RbExpr::str_strip_chars_start, 1),
394
+ )?;
395
+ class.define_method(
396
+ "str_strip_chars_end",
397
+ method!(RbExpr::str_strip_chars_end, 1),
398
+ )?;
399
+ class.define_method("str_strip_prefix", method!(RbExpr::str_strip_prefix, 1))?;
400
+ class.define_method("str_strip_suffix", method!(RbExpr::str_strip_suffix, 1))?;
339
401
  class.define_method("str_slice", method!(RbExpr::str_slice, 2))?;
402
+ class.define_method("str_explode", method!(RbExpr::str_explode, 0))?;
340
403
  class.define_method("str_to_uppercase", method!(RbExpr::str_to_uppercase, 0))?;
341
404
  class.define_method("str_to_lowercase", method!(RbExpr::str_to_lowercase, 0))?;
342
- class.define_method("str_lengths", method!(RbExpr::str_lengths, 0))?;
343
- class.define_method("str_n_chars", method!(RbExpr::str_n_chars, 0))?;
405
+ class.define_method("str_len_bytes", method!(RbExpr::str_len_bytes, 0))?;
406
+ class.define_method("str_len_chars", method!(RbExpr::str_len_chars, 0))?;
344
407
  class.define_method("str_replace_n", method!(RbExpr::str_replace_n, 4))?;
345
408
  class.define_method("str_replace_all", method!(RbExpr::str_replace_all, 3))?;
346
409
  class.define_method("str_zfill", method!(RbExpr::str_zfill, 1))?;
347
- class.define_method("str_ljust", method!(RbExpr::str_ljust, 2))?;
348
- class.define_method("str_rjust", method!(RbExpr::str_rjust, 2))?;
410
+ class.define_method("str_pad_start", method!(RbExpr::str_pad_start, 2))?;
411
+ class.define_method("str_pad_end", method!(RbExpr::str_pad_end, 2))?;
349
412
  class.define_method("str_contains", method!(RbExpr::str_contains, 3))?;
350
413
  class.define_method("str_ends_with", method!(RbExpr::str_ends_with, 1))?;
351
414
  class.define_method("str_starts_with", method!(RbExpr::str_starts_with, 1))?;
415
+ class.define_method("array_max", method!(RbExpr::array_max, 0))?;
416
+ class.define_method("array_min", method!(RbExpr::array_min, 0))?;
417
+ class.define_method("array_sum", method!(RbExpr::array_sum, 0))?;
352
418
  class.define_method("binary_contains", method!(RbExpr::bin_contains, 1))?;
353
419
  class.define_method("binary_ends_with", method!(RbExpr::bin_ends_with, 1))?;
354
420
  class.define_method("binary_starts_with", method!(RbExpr::bin_starts_with, 1))?;
@@ -356,8 +422,8 @@ fn init() -> RbResult<()> {
356
422
  class.define_method("str_hex_decode", method!(RbExpr::str_hex_decode, 1))?;
357
423
  class.define_method("str_base64_encode", method!(RbExpr::str_base64_encode, 0))?;
358
424
  class.define_method("str_base64_decode", method!(RbExpr::str_base64_decode, 1))?;
359
- class.define_method("str_parse_int", method!(RbExpr::str_parse_int, 2))?;
360
- class.define_method("str_json_extract", method!(RbExpr::str_json_extract, 1))?;
425
+ class.define_method("str_to_integer", method!(RbExpr::str_to_integer, 2))?;
426
+ class.define_method("str_json_extract", method!(RbExpr::str_json_extract, 2))?;
361
427
  class.define_method("binary_hex_encode", method!(RbExpr::bin_hex_encode, 0))?;
362
428
  class.define_method("binary_hex_decode", method!(RbExpr::bin_hex_decode, 1))?;
363
429
  class.define_method(
@@ -374,7 +440,7 @@ fn init() -> RbResult<()> {
374
440
  )?;
375
441
  class.define_method("str_extract", method!(RbExpr::str_extract, 2))?;
376
442
  class.define_method("str_extract_all", method!(RbExpr::str_extract_all, 1))?;
377
- class.define_method("count_match", method!(RbExpr::str_count_match, 1))?;
443
+ class.define_method("str_count_matches", method!(RbExpr::str_count_matches, 2))?;
378
444
  class.define_method("strftime", method!(RbExpr::dt_to_string, 1))?;
379
445
  class.define_method("str_split", method!(RbExpr::str_split, 1))?;
380
446
  class.define_method(
@@ -387,9 +453,9 @@ fn init() -> RbResult<()> {
387
453
  method!(RbExpr::str_split_exact_inclusive, 2),
388
454
  )?;
389
455
  class.define_method("str_splitn", method!(RbExpr::str_splitn, 2))?;
390
- class.define_method("list_lengths", method!(RbExpr::list_lengths, 0))?;
456
+ class.define_method("list_len", method!(RbExpr::list_len, 0))?;
391
457
  class.define_method("list_contains", method!(RbExpr::list_contains, 1))?;
392
- class.define_method("list_count_match", method!(RbExpr::list_count_match, 1))?;
458
+ class.define_method("list_count_matches", method!(RbExpr::list_count_matches, 1))?;
393
459
  class.define_method("year", method!(RbExpr::dt_year, 0))?;
394
460
  class.define_method("dt_is_leap_year", method!(RbExpr::dt_is_leap_year, 0))?;
395
461
  class.define_method("iso_year", method!(RbExpr::dt_iso_year, 0))?;
@@ -437,7 +503,6 @@ fn init() -> RbResult<()> {
437
503
  "dt_replace_time_zone",
438
504
  method!(RbExpr::dt_replace_time_zone, 2),
439
505
  )?;
440
- class.define_method("dt_tz_localize", method!(RbExpr::dt_tz_localize, 1))?;
441
506
  class.define_method("dt_truncate", method!(RbExpr::dt_truncate, 2))?;
442
507
  class.define_method("dt_month_start", method!(RbExpr::dt_month_start, 0))?;
443
508
  class.define_method("dt_month_end", method!(RbExpr::dt_month_end, 0))?;
@@ -447,18 +512,14 @@ fn init() -> RbResult<()> {
447
512
  class.define_method("dot", method!(RbExpr::dot, 1))?;
448
513
  class.define_method("reinterpret", method!(RbExpr::reinterpret, 1))?;
449
514
  class.define_method("mode", method!(RbExpr::mode, 0))?;
450
- class.define_method("keep_name", method!(RbExpr::keep_name, 0))?;
451
- class.define_method("prefix", method!(RbExpr::prefix, 1))?;
452
- class.define_method("suffix", method!(RbExpr::suffix, 1))?;
453
- class.define_method("map_alias", method!(RbExpr::map_alias, 1))?;
454
515
  class.define_method("exclude", method!(RbExpr::exclude, 1))?;
455
516
  class.define_method("interpolate", method!(RbExpr::interpolate, 1))?;
456
517
  class.define_method("rolling_sum", method!(RbExpr::rolling_sum, 6))?;
457
518
  class.define_method("rolling_min", method!(RbExpr::rolling_min, 6))?;
458
519
  class.define_method("rolling_max", method!(RbExpr::rolling_max, 6))?;
459
520
  class.define_method("rolling_mean", method!(RbExpr::rolling_mean, 6))?;
460
- class.define_method("rolling_std", method!(RbExpr::rolling_std, 6))?;
461
- class.define_method("rolling_var", method!(RbExpr::rolling_var, 6))?;
521
+ class.define_method("rolling_std", method!(RbExpr::rolling_std, 7))?;
522
+ class.define_method("rolling_var", method!(RbExpr::rolling_var, 7))?;
462
523
  class.define_method("rolling_median", method!(RbExpr::rolling_median, 6))?;
463
524
  class.define_method("rolling_quantile", method!(RbExpr::rolling_quantile, 8))?;
464
525
  class.define_method("rolling_skew", method!(RbExpr::rolling_skew, 2))?;
@@ -487,10 +548,10 @@ fn init() -> RbResult<()> {
487
548
  class.define_method("pct_change", method!(RbExpr::pct_change, 1))?;
488
549
  class.define_method("skew", method!(RbExpr::skew, 1))?;
489
550
  class.define_method("kurtosis", method!(RbExpr::kurtosis, 2))?;
490
- class.define_method("str_concat", method!(RbExpr::str_concat, 1))?;
551
+ class.define_method("str_concat", method!(RbExpr::str_concat, 2))?;
491
552
  class.define_method("cat_set_ordering", method!(RbExpr::cat_set_ordering, 1))?;
492
553
  class.define_method("reshape", method!(RbExpr::reshape, 1))?;
493
- class.define_method("cumcount", method!(RbExpr::cumcount, 1))?;
554
+ class.define_method("cum_count", method!(RbExpr::cum_count, 1))?;
494
555
  class.define_method("to_physical", method!(RbExpr::to_physical, 0))?;
495
556
  class.define_method("shuffle", method!(RbExpr::shuffle, 1))?;
496
557
  class.define_method("sample_n", method!(RbExpr::sample_n, 4))?;
@@ -499,8 +560,8 @@ fn init() -> RbResult<()> {
499
560
  class.define_method("ewm_std", method!(RbExpr::ewm_std, 5))?;
500
561
  class.define_method("ewm_var", method!(RbExpr::ewm_var, 5))?;
501
562
  class.define_method("extend_constant", method!(RbExpr::extend_constant, 2))?;
502
- class.define_method("any", method!(RbExpr::any, 0))?;
503
- class.define_method("all", method!(RbExpr::all, 0))?;
563
+ class.define_method("any", method!(RbExpr::any, 1))?;
564
+ class.define_method("all", method!(RbExpr::all, 1))?;
504
565
  class.define_method(
505
566
  "struct_field_by_name",
506
567
  method!(RbExpr::struct_field_by_name, 1),
@@ -517,6 +578,7 @@ fn init() -> RbResult<()> {
517
578
  class.define_method("exp", method!(RbExpr::exp, 0))?;
518
579
  class.define_method("entropy", method!(RbExpr::entropy, 2))?;
519
580
  class.define_method("_hash", method!(RbExpr::hash, 4))?;
581
+ class.define_method("set_sorted_flag", method!(RbExpr::set_sorted_flag, 1))?;
520
582
 
521
583
  // meta
522
584
  class.define_method("meta_pop", method!(RbExpr::meta_pop, 0))?;
@@ -533,6 +595,14 @@ fn init() -> RbResult<()> {
533
595
  method!(RbExpr::meta_is_regex_projection, 0),
534
596
  )?;
535
597
 
598
+ // name
599
+ class.define_method("name_keep", method!(RbExpr::name_keep, 0))?;
600
+ class.define_method("name_map", method!(RbExpr::name_map, 1))?;
601
+ class.define_method("name_prefix", method!(RbExpr::name_prefix, 1))?;
602
+ class.define_method("name_suffix", method!(RbExpr::name_suffix, 1))?;
603
+ class.define_method("name_to_lowercase", method!(RbExpr::name_to_lowercase, 0))?;
604
+ class.define_method("name_to_uppercase", method!(RbExpr::name_to_uppercase, 0))?;
605
+
536
606
  // maybe add to different class
537
607
  class.define_singleton_method("col", function!(crate::functions::lazy::col, 1))?;
538
608
  class.define_singleton_method("count", function!(crate::functions::lazy::count, 0))?;
@@ -541,9 +611,16 @@ fn init() -> RbResult<()> {
541
611
  class.define_singleton_method("cols", function!(crate::functions::lazy::cols, 1))?;
542
612
  class.define_singleton_method("fold", function!(crate::functions::lazy::fold, 3))?;
543
613
  class.define_singleton_method("cumfold", function!(crate::functions::lazy::cumfold, 4))?;
544
- class.define_singleton_method("lit", function!(crate::functions::lazy::lit, 1))?;
545
- class.define_singleton_method("arange", function!(crate::functions::lazy::arange, 3))?;
546
- class.define_singleton_method("repeat", function!(crate::functions::lazy::repeat, 2))?;
614
+ class.define_singleton_method("lit", function!(crate::functions::lazy::lit, 2))?;
615
+ class.define_singleton_method(
616
+ "int_range",
617
+ function!(crate::functions::range::int_range, 4),
618
+ )?;
619
+ class.define_singleton_method(
620
+ "int_ranges",
621
+ function!(crate::functions::range::int_ranges, 4),
622
+ )?;
623
+ class.define_singleton_method("repeat", function!(crate::functions::lazy::repeat, 3))?;
547
624
  class.define_singleton_method(
548
625
  "pearson_corr",
549
626
  function!(crate::functions::lazy::pearson_corr, 3),
@@ -552,7 +629,7 @@ fn init() -> RbResult<()> {
552
629
  "spearman_rank_corr",
553
630
  function!(crate::functions::lazy::spearman_rank_corr, 4),
554
631
  )?;
555
- class.define_singleton_method("cov", function!(crate::functions::lazy::cov, 2))?;
632
+ class.define_singleton_method("cov", function!(crate::functions::lazy::cov, 3))?;
556
633
  class.define_singleton_method(
557
634
  "arg_sort_by",
558
635
  function!(crate::functions::lazy::arg_sort_by, 2),
@@ -567,7 +644,7 @@ fn init() -> RbResult<()> {
567
644
  function!(crate::functions::lazy::concat_lst, 1),
568
645
  )?;
569
646
 
570
- let class = module.define_class("RbLazyFrame", Default::default())?;
647
+ let class = module.define_class("RbLazyFrame", ruby.class_object())?;
571
648
  class.define_singleton_method("read_json", function!(RbLazyFrame::read_json, 1))?;
572
649
  class.define_singleton_method(
573
650
  "new_from_ndjson",
@@ -576,7 +653,7 @@ fn init() -> RbResult<()> {
576
653
  class.define_singleton_method("new_from_csv", function!(RbLazyFrame::new_from_csv, -1))?;
577
654
  class.define_singleton_method(
578
655
  "new_from_parquet",
579
- function!(RbLazyFrame::new_from_parquet, 8),
656
+ function!(RbLazyFrame::new_from_parquet, 9),
580
657
  )?;
581
658
  class.define_singleton_method("new_from_ipc", function!(RbLazyFrame::new_from_ipc, 6))?;
582
659
  class.define_method("write_json", method!(RbLazyFrame::write_json, 1))?;
@@ -587,27 +664,32 @@ fn init() -> RbResult<()> {
587
664
  )?;
588
665
  class.define_method(
589
666
  "optimization_toggle",
590
- method!(RbLazyFrame::optimization_toggle, 7),
667
+ method!(RbLazyFrame::optimization_toggle, 8),
591
668
  )?;
592
- class.define_method("sort", method!(RbLazyFrame::sort, 3))?;
593
- class.define_method("sort_by_exprs", method!(RbLazyFrame::sort_by_exprs, 3))?;
669
+ class.define_method("sort", method!(RbLazyFrame::sort, 4))?;
670
+ class.define_method("sort_by_exprs", method!(RbLazyFrame::sort_by_exprs, 4))?;
594
671
  class.define_method("cache", method!(RbLazyFrame::cache, 0))?;
595
672
  class.define_method("collect", method!(RbLazyFrame::collect, 0))?;
596
673
  class.define_method("sink_parquet", method!(RbLazyFrame::sink_parquet, 7))?;
597
674
  class.define_method("fetch", method!(RbLazyFrame::fetch, 1))?;
598
675
  class.define_method("filter", method!(RbLazyFrame::filter, 1))?;
599
676
  class.define_method("select", method!(RbLazyFrame::select, 1))?;
600
- class.define_method("groupby", method!(RbLazyFrame::groupby, 2))?;
601
- class.define_method("groupby_rolling", method!(RbLazyFrame::groupby_rolling, 5))?;
602
- class.define_method("groupby_dynamic", method!(RbLazyFrame::groupby_dynamic, 9))?;
677
+ class.define_method("group_by", method!(RbLazyFrame::group_by, 2))?;
678
+ class.define_method(
679
+ "group_by_rolling",
680
+ method!(RbLazyFrame::group_by_rolling, 6),
681
+ )?;
682
+ class.define_method(
683
+ "group_by_dynamic",
684
+ method!(RbLazyFrame::group_by_dynamic, 10),
685
+ )?;
603
686
  class.define_method("with_context", method!(RbLazyFrame::with_context, 1))?;
604
687
  class.define_method("join_asof", method!(RbLazyFrame::join_asof, 11))?;
605
688
  class.define_method("join", method!(RbLazyFrame::join, 7))?;
606
689
  class.define_method("with_columns", method!(RbLazyFrame::with_columns, 1))?;
607
690
  class.define_method("rename", method!(RbLazyFrame::rename, 2))?;
608
691
  class.define_method("reverse", method!(RbLazyFrame::reverse, 0))?;
609
- class.define_method("shift", method!(RbLazyFrame::shift, 1))?;
610
- class.define_method("shift_and_fill", method!(RbLazyFrame::shift_and_fill, 2))?;
692
+ class.define_method("shift", method!(RbLazyFrame::shift, 2))?;
611
693
  class.define_method("fill_nan", method!(RbLazyFrame::fill_nan, 1))?;
612
694
  class.define_method("min", method!(RbLazyFrame::min, 0))?;
613
695
  class.define_method("max", method!(RbLazyFrame::max, 0))?;
@@ -632,12 +714,12 @@ fn init() -> RbResult<()> {
632
714
  class.define_method("unnest", method!(RbLazyFrame::unnest, 1))?;
633
715
  class.define_method("width", method!(RbLazyFrame::width, 0))?;
634
716
 
635
- let class = module.define_class("RbLazyGroupBy", Default::default())?;
717
+ let class = module.define_class("RbLazyGroupBy", ruby.class_object())?;
636
718
  class.define_method("agg", method!(RbLazyGroupBy::agg, 1))?;
637
719
  class.define_method("head", method!(RbLazyGroupBy::head, 1))?;
638
720
  class.define_method("tail", method!(RbLazyGroupBy::tail, 1))?;
639
721
 
640
- let class = module.define_class("RbSeries", Default::default())?;
722
+ let class = module.define_class("RbSeries", ruby.class_object())?;
641
723
  class.define_singleton_method("new_opt_bool", function!(RbSeries::new_opt_bool, 3))?;
642
724
  class.define_singleton_method("new_opt_u8", function!(RbSeries::new_opt_u8, 3))?;
643
725
  class.define_singleton_method("new_opt_u16", function!(RbSeries::new_opt_u16, 3))?;
@@ -658,6 +740,7 @@ fn init() -> RbResult<()> {
658
740
  class.define_singleton_method("new_null", function!(RbSeries::new_null, 3))?;
659
741
  class.define_singleton_method("new_object", function!(RbSeries::new_object, 3))?;
660
742
  class.define_singleton_method("new_series_list", function!(RbSeries::new_series_list, 3))?;
743
+ class.define_singleton_method("new_array", function!(RbSeries::new_array, 5))?;
661
744
  class.define_singleton_method("new_decimal", function!(RbSeries::new_decimal, 3))?;
662
745
  class.define_singleton_method("repeat", function!(RbSeries::repeat, 4))?;
663
746
  class.define_method("struct_unnest", method!(RbSeries::struct_unnest, 0))?;
@@ -725,9 +808,7 @@ fn init() -> RbResult<()> {
725
808
  class.define_method("_clone", method!(RbSeries::clone, 0))?;
726
809
  class.define_method("apply_lambda", method!(RbSeries::apply_lambda, 3))?;
727
810
  class.define_method("zip_with", method!(RbSeries::zip_with, 2))?;
728
- class.define_method("to_dummies", method!(RbSeries::to_dummies, 1))?;
729
- class.define_method("peak_max", method!(RbSeries::peak_max, 0))?;
730
- class.define_method("peak_min", method!(RbSeries::peak_min, 0))?;
811
+ class.define_method("to_dummies", method!(RbSeries::to_dummies, 2))?;
731
812
  class.define_method("n_unique", method!(RbSeries::n_unique, 0))?;
732
813
  class.define_method("floor", method!(RbSeries::floor, 0))?;
733
814
  class.define_method("shrink_to_fit", method!(RbSeries::shrink_to_fit, 0))?;
@@ -897,11 +978,19 @@ fn init() -> RbResult<()> {
897
978
  // extra
898
979
  class.define_method("extend_constant", method!(RbSeries::extend_constant, 2))?;
899
980
 
900
- let class = module.define_class("RbWhen", Default::default())?;
981
+ let class = module.define_class("RbWhen", ruby.class_object())?;
901
982
  class.define_method("_then", method!(RbWhen::then, 1))?;
902
983
 
903
- let class = module.define_class("RbWhenThen", Default::default())?;
904
- class.define_method("otherwise", method!(RbWhenThen::overwise, 1))?;
984
+ let class = module.define_class("RbWhenThen", ruby.class_object())?;
985
+ class.define_method("otherwise", method!(RbThen::overwise, 1))?;
986
+
987
+ // sql
988
+ let class = module.define_class("RbSQLContext", ruby.class_object())?;
989
+ class.define_singleton_method("new", function!(RbSQLContext::new, 0))?;
990
+ class.define_method("execute", method!(RbSQLContext::execute, 1))?;
991
+ class.define_method("get_tables", method!(RbSQLContext::get_tables, 0))?;
992
+ class.define_method("register", method!(RbSQLContext::register, 2))?;
993
+ class.define_method("unregister", method!(RbSQLContext::unregister, 1))?;
905
994
 
906
995
  Ok(())
907
996
  }