polars-df 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/Cargo.lock +597 -599
  4. data/Cargo.toml +1 -0
  5. data/README.md +8 -7
  6. data/ext/polars/Cargo.toml +20 -10
  7. data/ext/polars/src/batched_csv.rs +27 -28
  8. data/ext/polars/src/conversion.rs +135 -106
  9. data/ext/polars/src/dataframe.rs +140 -131
  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/categorical.rs +8 -1
  13. data/ext/polars/src/expr/datetime.rs +10 -12
  14. data/ext/polars/src/expr/general.rs +129 -286
  15. data/ext/polars/src/expr/list.rs +17 -9
  16. data/ext/polars/src/{expr.rs → expr/mod.rs} +4 -2
  17. data/ext/polars/src/expr/name.rs +44 -0
  18. data/ext/polars/src/expr/rolling.rs +201 -0
  19. data/ext/polars/src/expr/string.rs +94 -67
  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 +66 -41
  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 +41 -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 +74 -60
  33. data/ext/polars/src/lib.rs +175 -91
  34. data/ext/polars/src/{apply → map}/dataframe.rs +29 -34
  35. data/ext/polars/src/{apply → map}/mod.rs +5 -5
  36. data/ext/polars/src/{apply → map}/series.rs +18 -22
  37. data/ext/polars/src/object.rs +0 -30
  38. data/ext/polars/src/on_startup.rs +32 -0
  39. data/ext/polars/src/rb_modules.rs +22 -7
  40. data/ext/polars/src/series/aggregation.rs +3 -0
  41. data/ext/polars/src/series/construction.rs +5 -5
  42. data/ext/polars/src/series/export.rs +4 -4
  43. data/ext/polars/src/{series.rs → series/mod.rs} +28 -45
  44. data/ext/polars/src/series/{set_at_idx.rs → scatter.rs} +38 -22
  45. data/ext/polars/src/sql.rs +46 -0
  46. data/ext/polars/src/utils.rs +1 -1
  47. data/lib/polars/config.rb +530 -0
  48. data/lib/polars/data_frame.rb +182 -145
  49. data/lib/polars/data_types.rb +4 -1
  50. data/lib/polars/date_time_expr.rb +23 -28
  51. data/lib/polars/date_time_name_space.rb +17 -37
  52. data/lib/polars/dynamic_group_by.rb +2 -2
  53. data/lib/polars/expr.rb +398 -110
  54. data/lib/polars/functions.rb +29 -37
  55. data/lib/polars/group_by.rb +38 -55
  56. data/lib/polars/io.rb +40 -5
  57. data/lib/polars/lazy_frame.rb +116 -89
  58. data/lib/polars/lazy_functions.rb +40 -68
  59. data/lib/polars/lazy_group_by.rb +7 -8
  60. data/lib/polars/list_expr.rb +12 -8
  61. data/lib/polars/list_name_space.rb +2 -2
  62. data/lib/polars/name_expr.rb +198 -0
  63. data/lib/polars/rolling_group_by.rb +2 -2
  64. data/lib/polars/series.rb +315 -43
  65. data/lib/polars/sql_context.rb +194 -0
  66. data/lib/polars/string_expr.rb +114 -60
  67. data/lib/polars/string_name_space.rb +19 -4
  68. data/lib/polars/struct_expr.rb +1 -1
  69. data/lib/polars/struct_name_space.rb +1 -1
  70. data/lib/polars/utils.rb +25 -13
  71. data/lib/polars/version.rb +1 -1
  72. data/lib/polars.rb +3 -0
  73. metadata +23 -11
  74. /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,10 +7,13 @@ mod file;
8
7
  mod functions;
9
8
  mod lazyframe;
10
9
  mod lazygroupby;
10
+ mod map;
11
+ mod on_startup;
11
12
  mod object;
12
13
  mod prelude;
13
14
  pub(crate) mod rb_modules;
14
15
  mod series;
16
+ mod sql;
15
17
  mod utils;
16
18
 
17
19
  use batched_csv::RbBatchedCsv;
@@ -20,11 +22,12 @@ use dataframe::RbDataFrame;
20
22
  use error::{RbPolarsErr, RbTypeError, RbValueError};
21
23
  use expr::rb_exprs_to_exprs;
22
24
  use expr::RbExpr;
23
- use functions::whenthen::{RbWhen, RbWhenThen};
25
+ use functions::whenthen::{RbThen, RbWhen};
24
26
  use lazyframe::RbLazyFrame;
25
27
  use lazygroupby::RbLazyGroupBy;
26
- use magnus::{define_module, function, method, prelude::*, Error};
28
+ use magnus::{define_module, function, method, prelude::*, Error, Ruby};
27
29
  use series::RbSeries;
30
+ use sql::RbSQLContext;
28
31
 
29
32
  #[cfg(target_os = "linux")]
30
33
  use jemallocator::Jemalloc;
@@ -43,15 +46,19 @@ static GLOBAL: MiMalloc = MiMalloc;
43
46
  type RbResult<T> = Result<T, Error>;
44
47
 
45
48
  #[magnus::init]
46
- fn init() -> RbResult<()> {
49
+ fn init(ruby: &Ruby) -> RbResult<()> {
47
50
  let module = define_module("Polars")?;
48
51
  module.define_singleton_method(
49
52
  "_dtype_cols",
50
53
  function!(crate::functions::lazy::dtype_cols2, 1),
51
54
  )?;
55
+ module.define_singleton_method(
56
+ "_concat_lf_diagonal",
57
+ function!(crate::functions::lazy::concat_lf_diagonal, 4),
58
+ )?;
52
59
  module.define_singleton_method(
53
60
  "_rb_duration",
54
- function!(crate::functions::lazy::duration, 8),
61
+ function!(crate::functions::lazy::duration, 9),
55
62
  )?;
56
63
  module.define_singleton_method(
57
64
  "_concat_df",
@@ -62,12 +69,12 @@ fn init() -> RbResult<()> {
62
69
  function!(crate::functions::lazy::concat_lf, 4),
63
70
  )?;
64
71
  module.define_singleton_method(
65
- "_diag_concat_df",
66
- function!(crate::functions::eager::diag_concat_df, 1),
72
+ "_concat_df_diagonal",
73
+ function!(crate::functions::eager::concat_df_diagonal, 1),
67
74
  )?;
68
75
  module.define_singleton_method(
69
- "_hor_concat_df",
70
- function!(crate::functions::eager::hor_concat_df, 1),
76
+ "_concat_df_horizontal",
77
+ function!(crate::functions::eager::concat_df_horizontal, 1),
71
78
  )?;
72
79
  module.define_singleton_method(
73
80
  "_concat_series",
@@ -87,15 +94,35 @@ fn init() -> RbResult<()> {
87
94
  )?;
88
95
  module.define_singleton_method(
89
96
  "_rb_date_range",
90
- function!(crate::functions::eager::date_range, 7),
97
+ function!(crate::functions::range::date_range, 6),
91
98
  )?;
92
99
  module.define_singleton_method(
93
100
  "_coalesce_exprs",
94
101
  function!(crate::functions::lazy::coalesce, 1),
95
102
  )?;
96
103
  module.define_singleton_method(
97
- "_sum_exprs",
98
- function!(crate::functions::lazy::sum_exprs, 1),
104
+ "_all_horizontal",
105
+ function!(crate::functions::aggregation::all_horizontal, 1),
106
+ )?;
107
+ module.define_singleton_method(
108
+ "_any_horizontal",
109
+ function!(crate::functions::aggregation::any_horizontal, 1),
110
+ )?;
111
+ module.define_singleton_method(
112
+ "_max_horizontal",
113
+ function!(crate::functions::aggregation::max_horizontal, 1),
114
+ )?;
115
+ module.define_singleton_method(
116
+ "_min_horizontal",
117
+ function!(crate::functions::aggregation::min_horizontal, 1),
118
+ )?;
119
+ module.define_singleton_method(
120
+ "_sum_horizontal",
121
+ function!(crate::functions::aggregation::sum_horizontal, 1),
122
+ )?;
123
+ module.define_singleton_method(
124
+ "_dtype_str_repr",
125
+ function!(crate::functions::misc::dtype_str_repr, 1),
99
126
  )?;
100
127
  module.define_singleton_method(
101
128
  "_as_struct",
@@ -109,17 +136,46 @@ fn init() -> RbResult<()> {
109
136
  "_get_idx_type",
110
137
  function!(crate::functions::meta::get_idx_type, 0),
111
138
  )?;
139
+ module.define_singleton_method(
140
+ "_threadpool_size",
141
+ function!(crate::functions::meta::threadpool_size, 0),
142
+ )?;
143
+ module.define_singleton_method(
144
+ "_enable_string_cache",
145
+ function!(crate::functions::string_cache::enable_string_cache, 0),
146
+ )?;
147
+ module.define_singleton_method(
148
+ "_disable_string_cache",
149
+ function!(crate::functions::string_cache::disable_string_cache, 0),
150
+ )?;
151
+ module.define_singleton_method(
152
+ "_using_string_cache",
153
+ function!(crate::functions::string_cache::using_string_cache, 0),
154
+ )?;
155
+ module.define_singleton_method(
156
+ "_set_float_fmt",
157
+ function!(crate::functions::meta::set_float_fmt, 1),
158
+ )?;
159
+ module.define_singleton_method(
160
+ "_get_float_fmt",
161
+ function!(crate::functions::meta::get_float_fmt, 0),
162
+ )?;
163
+ module.define_singleton_method(
164
+ "_set_random_seed",
165
+ function!(crate::functions::random::set_random_seed, 1),
166
+ )?;
112
167
 
113
- let class = module.define_class("RbBatchedCsv", Default::default())?;
168
+ let class = module.define_class("RbBatchedCsv", ruby.class_object())?;
114
169
  class.define_singleton_method("new", function!(RbBatchedCsv::new, -1))?;
115
170
  class.define_method("next_batches", method!(RbBatchedCsv::next_batches, 1))?;
116
171
 
117
- let class = module.define_class("RbDataFrame", Default::default())?;
172
+ let class = module.define_class("RbDataFrame", ruby.class_object())?;
118
173
  class.define_singleton_method("new", function!(RbDataFrame::init, 1))?;
119
174
  class.define_singleton_method("read_csv", function!(RbDataFrame::read_csv, -1))?;
120
175
  class.define_singleton_method("read_parquet", function!(RbDataFrame::read_parquet, 9))?;
121
176
  class.define_singleton_method("read_ipc", function!(RbDataFrame::read_ipc, 6))?;
122
177
  class.define_singleton_method("read_avro", function!(RbDataFrame::read_avro, 4))?;
178
+ class.define_singleton_method("read_rows", function!(RbDataFrame::read_rows, 3))?;
123
179
  class.define_singleton_method("read_hashes", function!(RbDataFrame::read_hashes, 3))?;
124
180
  class.define_singleton_method("read_hash", function!(RbDataFrame::read_hash, 1))?;
125
181
  class.define_singleton_method("read_json", function!(RbDataFrame::read_json, 1))?;
@@ -169,8 +225,8 @@ fn init() -> RbResult<()> {
169
225
  class.define_method("drop", method!(RbDataFrame::drop, 1))?;
170
226
  class.define_method("select_at_idx", method!(RbDataFrame::select_at_idx, 1))?;
171
227
  class.define_method(
172
- "find_idx_by_name",
173
- method!(RbDataFrame::find_idx_by_name, 1),
228
+ "get_column_index",
229
+ method!(RbDataFrame::get_column_index, 1),
174
230
  )?;
175
231
  class.define_method("column", method!(RbDataFrame::column, 1))?;
176
232
  class.define_method("select", method!(RbDataFrame::select, 1))?;
@@ -180,14 +236,14 @@ fn init() -> RbResult<()> {
180
236
  method!(RbDataFrame::take_with_series, 1),
181
237
  )?;
182
238
  class.define_method("replace", method!(RbDataFrame::replace, 2))?;
183
- class.define_method("replace_at_idx", method!(RbDataFrame::replace_at_idx, 2))?;
184
- class.define_method("insert_at_idx", method!(RbDataFrame::insert_at_idx, 2))?;
239
+ class.define_method("replace_column", method!(RbDataFrame::replace_column, 2))?;
240
+ class.define_method("insert_column", method!(RbDataFrame::insert_column, 2))?;
185
241
  class.define_method("slice", method!(RbDataFrame::slice, 2))?;
186
242
  class.define_method("head", method!(RbDataFrame::head, 1))?;
187
243
  class.define_method("tail", method!(RbDataFrame::tail, 1))?;
188
244
  class.define_method("is_unique", method!(RbDataFrame::is_unique, 0))?;
189
245
  class.define_method("is_duplicated", method!(RbDataFrame::is_duplicated, 0))?;
190
- class.define_method("frame_equal", method!(RbDataFrame::frame_equal, 2))?;
246
+ class.define_method("equals", method!(RbDataFrame::equals, 2))?;
191
247
  class.define_method("with_row_count", method!(RbDataFrame::with_row_count, 2))?;
192
248
  class.define_method("_clone", method!(RbDataFrame::clone, 0))?;
193
249
  class.define_method("melt", method!(RbDataFrame::melt, 4))?;
@@ -195,18 +251,10 @@ fn init() -> RbResult<()> {
195
251
  class.define_method("partition_by", method!(RbDataFrame::partition_by, 3))?;
196
252
  class.define_method("shift", method!(RbDataFrame::shift, 1))?;
197
253
  class.define_method("lazy", method!(RbDataFrame::lazy, 0))?;
198
- class.define_method("max", method!(RbDataFrame::max, 0))?;
199
- class.define_method("min", method!(RbDataFrame::min, 0))?;
200
- class.define_method("sum", method!(RbDataFrame::sum, 0))?;
201
- class.define_method("mean", method!(RbDataFrame::mean, 0))?;
202
- class.define_method("std", method!(RbDataFrame::std, 1))?;
203
- class.define_method("var", method!(RbDataFrame::var, 1))?;
204
- class.define_method("median", method!(RbDataFrame::median, 0))?;
205
- class.define_method("hmean", method!(RbDataFrame::hmean, 1))?;
206
- class.define_method("hmax", method!(RbDataFrame::hmax, 0))?;
207
- class.define_method("hmin", method!(RbDataFrame::hmin, 0))?;
208
- class.define_method("hsum", method!(RbDataFrame::hsum, 1))?;
209
- class.define_method("quantile", method!(RbDataFrame::quantile, 2))?;
254
+ class.define_method("mean_horizontal", method!(RbDataFrame::mean_horizontal, 1))?;
255
+ class.define_method("max_horizontal", method!(RbDataFrame::max_horizontal, 0))?;
256
+ class.define_method("min_horizontal", method!(RbDataFrame::min_horizontal, 0))?;
257
+ class.define_method("sum_horizontal", method!(RbDataFrame::sum_horizontal, 1))?;
210
258
  class.define_method("to_dummies", method!(RbDataFrame::to_dummies, 3))?;
211
259
  class.define_method("null_count", method!(RbDataFrame::null_count, 0))?;
212
260
  class.define_method("apply", method!(RbDataFrame::apply, 3))?;
@@ -217,7 +265,7 @@ fn init() -> RbResult<()> {
217
265
  class.define_method("to_struct", method!(RbDataFrame::to_struct, 1))?;
218
266
  class.define_method("unnest", method!(RbDataFrame::unnest, 1))?;
219
267
 
220
- let class = module.define_class("RbExpr", Default::default())?;
268
+ let class = module.define_class("RbExpr", ruby.class_object())?;
221
269
  class.define_method("+", method!(RbExpr::add, 1))?;
222
270
  class.define_method("-", method!(RbExpr::sub, 1))?;
223
271
  class.define_method("*", method!(RbExpr::mul, 1))?;
@@ -254,8 +302,14 @@ fn init() -> RbResult<()> {
254
302
  class.define_method("last", method!(RbExpr::last, 0))?;
255
303
  class.define_method("implode", method!(RbExpr::implode, 0))?;
256
304
  class.define_method("quantile", method!(RbExpr::quantile, 2))?;
305
+ class.define_method("cut", method!(RbExpr::cut, 4))?;
306
+ class.define_method("qcut", method!(RbExpr::qcut, 5))?;
307
+ class.define_method("qcut_uniform", method!(RbExpr::qcut_uniform, 5))?;
308
+ class.define_method("rle", method!(RbExpr::rle, 0))?;
309
+ class.define_method("rle_id", method!(RbExpr::rle_id, 0))?;
257
310
  class.define_method("agg_groups", method!(RbExpr::agg_groups, 0))?;
258
311
  class.define_method("count", method!(RbExpr::count, 0))?;
312
+ class.define_method("len", method!(RbExpr::len, 0))?;
259
313
  class.define_method("value_counts", method!(RbExpr::value_counts, 2))?;
260
314
  class.define_method("unique_counts", method!(RbExpr::unique_counts, 0))?;
261
315
  class.define_method("null_count", method!(RbExpr::null_count, 0))?;
@@ -264,15 +318,16 @@ fn init() -> RbResult<()> {
264
318
  class.define_method("arg_sort", method!(RbExpr::arg_sort, 2))?;
265
319
  class.define_method("top_k", method!(RbExpr::top_k, 1))?;
266
320
  class.define_method("bottom_k", method!(RbExpr::bottom_k, 1))?;
321
+ class.define_method("peak_min", method!(RbExpr::peak_min, 0))?;
322
+ class.define_method("peak_max", method!(RbExpr::peak_max, 0))?;
267
323
  class.define_method("arg_max", method!(RbExpr::arg_max, 0))?;
268
324
  class.define_method("arg_min", method!(RbExpr::arg_min, 0))?;
269
325
  class.define_method("search_sorted", method!(RbExpr::search_sorted, 2))?;
270
- class.define_method("take", method!(RbExpr::take, 1))?;
326
+ class.define_method("gather", method!(RbExpr::gather, 1))?;
271
327
  class.define_method("sort_by", method!(RbExpr::sort_by, 2))?;
272
328
  class.define_method("backward_fill", method!(RbExpr::backward_fill, 1))?;
273
329
  class.define_method("forward_fill", method!(RbExpr::forward_fill, 1))?;
274
- class.define_method("shift", method!(RbExpr::shift, 1))?;
275
- class.define_method("shift_and_fill", method!(RbExpr::shift_and_fill, 2))?;
330
+ class.define_method("shift", method!(RbExpr::shift, 2))?;
276
331
  class.define_method("fill_null", method!(RbExpr::fill_null, 1))?;
277
332
  class.define_method(
278
333
  "fill_null_with_strategy",
@@ -286,10 +341,11 @@ fn init() -> RbResult<()> {
286
341
  class.define_method("std", method!(RbExpr::std, 1))?;
287
342
  class.define_method("var", method!(RbExpr::var, 1))?;
288
343
  class.define_method("is_unique", method!(RbExpr::is_unique, 0))?;
289
- class.define_method("approx_unique", method!(RbExpr::approx_unique, 0))?;
290
- class.define_method("is_first", method!(RbExpr::is_first, 0))?;
344
+ class.define_method("approx_n_unique", method!(RbExpr::approx_n_unique, 0))?;
345
+ class.define_method("is_first_distinct", method!(RbExpr::is_first_distinct, 0))?;
346
+ class.define_method("is_last_distinct", method!(RbExpr::is_last_distinct, 0))?;
291
347
  class.define_method("explode", method!(RbExpr::explode, 0))?;
292
- class.define_method("take_every", method!(RbExpr::take_every, 1))?;
348
+ class.define_method("gather_every", method!(RbExpr::gather_every, 2))?;
293
349
  class.define_method("tail", method!(RbExpr::tail, 1))?;
294
350
  class.define_method("head", method!(RbExpr::head, 1))?;
295
351
  class.define_method("slice", method!(RbExpr::slice, 2))?;
@@ -299,8 +355,6 @@ fn init() -> RbResult<()> {
299
355
  class.define_method("floor", method!(RbExpr::floor, 0))?;
300
356
  class.define_method("ceil", method!(RbExpr::ceil, 0))?;
301
357
  class.define_method("clip", method!(RbExpr::clip, 2))?;
302
- class.define_method("clip_min", method!(RbExpr::clip_min, 1))?;
303
- class.define_method("clip_max", method!(RbExpr::clip_max, 1))?;
304
358
  class.define_method("abs", method!(RbExpr::abs, 0))?;
305
359
  class.define_method("sin", method!(RbExpr::sin, 0))?;
306
360
  class.define_method("cos", method!(RbExpr::cos, 0))?;
@@ -323,29 +377,37 @@ fn init() -> RbResult<()> {
323
377
  class.define_method("is_in", method!(RbExpr::is_in, 1))?;
324
378
  class.define_method("repeat_by", method!(RbExpr::repeat_by, 1))?;
325
379
  class.define_method("pow", method!(RbExpr::pow, 1))?;
326
- class.define_method("cumsum", method!(RbExpr::cumsum, 1))?;
327
- class.define_method("cummax", method!(RbExpr::cummax, 1))?;
328
- class.define_method("cummin", method!(RbExpr::cummin, 1))?;
329
- class.define_method("cumprod", method!(RbExpr::cumprod, 1))?;
380
+ class.define_method("cum_sum", method!(RbExpr::cum_sum, 1))?;
381
+ class.define_method("cum_max", method!(RbExpr::cum_max, 1))?;
382
+ class.define_method("cum_min", method!(RbExpr::cum_min, 1))?;
383
+ class.define_method("cum_prod", method!(RbExpr::cum_prod, 1))?;
330
384
  class.define_method("product", method!(RbExpr::product, 0))?;
331
385
  class.define_method("shrink_dtype", method!(RbExpr::shrink_dtype, 0))?;
332
386
  class.define_method("str_to_date", method!(RbExpr::str_to_date, 4))?;
333
- class.define_method("str_to_datetime", method!(RbExpr::str_to_datetime, 6))?;
387
+ class.define_method("str_to_datetime", method!(RbExpr::str_to_datetime, 7))?;
334
388
  class.define_method("str_to_time", method!(RbExpr::str_to_time, 3))?;
335
- class.define_method("str_strip", method!(RbExpr::str_strip, 1))?;
336
- class.define_method("str_rstrip", method!(RbExpr::str_rstrip, 1))?;
337
- class.define_method("str_lstrip", method!(RbExpr::str_lstrip, 1))?;
389
+ class.define_method("str_strip_chars", method!(RbExpr::str_strip_chars, 1))?;
390
+ class.define_method(
391
+ "str_strip_chars_start",
392
+ method!(RbExpr::str_strip_chars_start, 1),
393
+ )?;
394
+ class.define_method(
395
+ "str_strip_chars_end",
396
+ method!(RbExpr::str_strip_chars_end, 1),
397
+ )?;
398
+ class.define_method("str_strip_prefix", method!(RbExpr::str_strip_prefix, 1))?;
399
+ class.define_method("str_strip_suffix", method!(RbExpr::str_strip_suffix, 1))?;
338
400
  class.define_method("str_slice", method!(RbExpr::str_slice, 2))?;
339
401
  class.define_method("str_explode", method!(RbExpr::str_explode, 0))?;
340
402
  class.define_method("str_to_uppercase", method!(RbExpr::str_to_uppercase, 0))?;
341
403
  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))?;
404
+ class.define_method("str_len_bytes", method!(RbExpr::str_len_bytes, 0))?;
405
+ class.define_method("str_len_chars", method!(RbExpr::str_len_chars, 0))?;
344
406
  class.define_method("str_replace_n", method!(RbExpr::str_replace_n, 4))?;
345
407
  class.define_method("str_replace_all", method!(RbExpr::str_replace_all, 3))?;
346
408
  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))?;
409
+ class.define_method("str_pad_start", method!(RbExpr::str_pad_start, 2))?;
410
+ class.define_method("str_pad_end", method!(RbExpr::str_pad_end, 2))?;
349
411
  class.define_method("str_contains", method!(RbExpr::str_contains, 3))?;
350
412
  class.define_method("str_ends_with", method!(RbExpr::str_ends_with, 1))?;
351
413
  class.define_method("str_starts_with", method!(RbExpr::str_starts_with, 1))?;
@@ -359,7 +421,7 @@ fn init() -> RbResult<()> {
359
421
  class.define_method("str_hex_decode", method!(RbExpr::str_hex_decode, 1))?;
360
422
  class.define_method("str_base64_encode", method!(RbExpr::str_base64_encode, 0))?;
361
423
  class.define_method("str_base64_decode", method!(RbExpr::str_base64_decode, 1))?;
362
- class.define_method("str_parse_int", method!(RbExpr::str_parse_int, 2))?;
424
+ class.define_method("str_to_integer", method!(RbExpr::str_to_integer, 2))?;
363
425
  class.define_method("str_json_extract", method!(RbExpr::str_json_extract, 2))?;
364
426
  class.define_method("binary_hex_encode", method!(RbExpr::bin_hex_encode, 0))?;
365
427
  class.define_method("binary_hex_decode", method!(RbExpr::bin_hex_decode, 1))?;
@@ -377,7 +439,7 @@ fn init() -> RbResult<()> {
377
439
  )?;
378
440
  class.define_method("str_extract", method!(RbExpr::str_extract, 2))?;
379
441
  class.define_method("str_extract_all", method!(RbExpr::str_extract_all, 1))?;
380
- class.define_method("count_match", method!(RbExpr::str_count_match, 1))?;
442
+ class.define_method("str_count_matches", method!(RbExpr::str_count_matches, 2))?;
381
443
  class.define_method("strftime", method!(RbExpr::dt_to_string, 1))?;
382
444
  class.define_method("str_split", method!(RbExpr::str_split, 1))?;
383
445
  class.define_method(
@@ -390,9 +452,9 @@ fn init() -> RbResult<()> {
390
452
  method!(RbExpr::str_split_exact_inclusive, 2),
391
453
  )?;
392
454
  class.define_method("str_splitn", method!(RbExpr::str_splitn, 2))?;
393
- class.define_method("list_lengths", method!(RbExpr::list_lengths, 0))?;
455
+ class.define_method("list_len", method!(RbExpr::list_len, 0))?;
394
456
  class.define_method("list_contains", method!(RbExpr::list_contains, 1))?;
395
- class.define_method("list_count_match", method!(RbExpr::list_count_match, 1))?;
457
+ class.define_method("list_count_matches", method!(RbExpr::list_count_matches, 1))?;
396
458
  class.define_method("year", method!(RbExpr::dt_year, 0))?;
397
459
  class.define_method("dt_is_leap_year", method!(RbExpr::dt_is_leap_year, 0))?;
398
460
  class.define_method("iso_year", method!(RbExpr::dt_iso_year, 0))?;
@@ -440,7 +502,6 @@ fn init() -> RbResult<()> {
440
502
  "dt_replace_time_zone",
441
503
  method!(RbExpr::dt_replace_time_zone, 2),
442
504
  )?;
443
- class.define_method("dt_tz_localize", method!(RbExpr::dt_tz_localize, 1))?;
444
505
  class.define_method("dt_truncate", method!(RbExpr::dt_truncate, 2))?;
445
506
  class.define_method("dt_month_start", method!(RbExpr::dt_month_start, 0))?;
446
507
  class.define_method("dt_month_end", method!(RbExpr::dt_month_end, 0))?;
@@ -450,20 +511,16 @@ fn init() -> RbResult<()> {
450
511
  class.define_method("dot", method!(RbExpr::dot, 1))?;
451
512
  class.define_method("reinterpret", method!(RbExpr::reinterpret, 1))?;
452
513
  class.define_method("mode", method!(RbExpr::mode, 0))?;
453
- class.define_method("keep_name", method!(RbExpr::keep_name, 0))?;
454
- class.define_method("prefix", method!(RbExpr::prefix, 1))?;
455
- class.define_method("suffix", method!(RbExpr::suffix, 1))?;
456
- class.define_method("map_alias", method!(RbExpr::map_alias, 1))?;
457
514
  class.define_method("exclude", method!(RbExpr::exclude, 1))?;
458
515
  class.define_method("interpolate", method!(RbExpr::interpolate, 1))?;
459
516
  class.define_method("rolling_sum", method!(RbExpr::rolling_sum, 6))?;
460
517
  class.define_method("rolling_min", method!(RbExpr::rolling_min, 6))?;
461
518
  class.define_method("rolling_max", method!(RbExpr::rolling_max, 6))?;
462
519
  class.define_method("rolling_mean", method!(RbExpr::rolling_mean, 6))?;
463
- class.define_method("rolling_std", method!(RbExpr::rolling_std, 7))?;
464
- class.define_method("rolling_var", method!(RbExpr::rolling_var, 7))?;
465
- class.define_method("rolling_median", method!(RbExpr::rolling_median, 6))?;
466
- class.define_method("rolling_quantile", method!(RbExpr::rolling_quantile, 8))?;
520
+ class.define_method("rolling_std", method!(RbExpr::rolling_std, 8))?;
521
+ class.define_method("rolling_var", method!(RbExpr::rolling_var, 8))?;
522
+ class.define_method("rolling_median", method!(RbExpr::rolling_median, 7))?;
523
+ class.define_method("rolling_quantile", method!(RbExpr::rolling_quantile, 9))?;
467
524
  class.define_method("rolling_skew", method!(RbExpr::rolling_skew, 2))?;
468
525
  class.define_method("lower_bound", method!(RbExpr::lower_bound, 0))?;
469
526
  class.define_method("upper_bound", method!(RbExpr::upper_bound, 0))?;
@@ -490,20 +547,21 @@ fn init() -> RbResult<()> {
490
547
  class.define_method("pct_change", method!(RbExpr::pct_change, 1))?;
491
548
  class.define_method("skew", method!(RbExpr::skew, 1))?;
492
549
  class.define_method("kurtosis", method!(RbExpr::kurtosis, 2))?;
493
- class.define_method("str_concat", method!(RbExpr::str_concat, 1))?;
550
+ class.define_method("str_concat", method!(RbExpr::str_concat, 2))?;
494
551
  class.define_method("cat_set_ordering", method!(RbExpr::cat_set_ordering, 1))?;
552
+ class.define_method("cat_get_categories", method!(RbExpr::cat_get_categories, 0))?;
495
553
  class.define_method("reshape", method!(RbExpr::reshape, 1))?;
496
- class.define_method("cumcount", method!(RbExpr::cumcount, 1))?;
554
+ class.define_method("cum_count", method!(RbExpr::cum_count, 1))?;
497
555
  class.define_method("to_physical", method!(RbExpr::to_physical, 0))?;
498
- class.define_method("shuffle", method!(RbExpr::shuffle, 2))?;
499
- class.define_method("sample_n", method!(RbExpr::sample_n, 5))?;
500
- class.define_method("sample_frac", method!(RbExpr::sample_frac, 5))?;
556
+ class.define_method("shuffle", method!(RbExpr::shuffle, 1))?;
557
+ class.define_method("sample_n", method!(RbExpr::sample_n, 4))?;
558
+ class.define_method("sample_frac", method!(RbExpr::sample_frac, 4))?;
501
559
  class.define_method("ewm_mean", method!(RbExpr::ewm_mean, 4))?;
502
560
  class.define_method("ewm_std", method!(RbExpr::ewm_std, 5))?;
503
561
  class.define_method("ewm_var", method!(RbExpr::ewm_var, 5))?;
504
562
  class.define_method("extend_constant", method!(RbExpr::extend_constant, 2))?;
505
- class.define_method("any", method!(RbExpr::any, 0))?;
506
- 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))?;
507
565
  class.define_method(
508
566
  "struct_field_by_name",
509
567
  method!(RbExpr::struct_field_by_name, 1),
@@ -537,6 +595,14 @@ fn init() -> RbResult<()> {
537
595
  method!(RbExpr::meta_is_regex_projection, 0),
538
596
  )?;
539
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
+
540
606
  // maybe add to different class
541
607
  class.define_singleton_method("col", function!(crate::functions::lazy::col, 1))?;
542
608
  class.define_singleton_method("count", function!(crate::functions::lazy::count, 0))?;
@@ -546,7 +612,14 @@ fn init() -> RbResult<()> {
546
612
  class.define_singleton_method("fold", function!(crate::functions::lazy::fold, 3))?;
547
613
  class.define_singleton_method("cumfold", function!(crate::functions::lazy::cumfold, 4))?;
548
614
  class.define_singleton_method("lit", function!(crate::functions::lazy::lit, 2))?;
549
- class.define_singleton_method("arange", function!(crate::functions::lazy::arange, 3))?;
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
+ )?;
550
623
  class.define_singleton_method("repeat", function!(crate::functions::lazy::repeat, 3))?;
551
624
  class.define_singleton_method(
552
625
  "pearson_corr",
@@ -556,7 +629,7 @@ fn init() -> RbResult<()> {
556
629
  "spearman_rank_corr",
557
630
  function!(crate::functions::lazy::spearman_rank_corr, 4),
558
631
  )?;
559
- class.define_singleton_method("cov", function!(crate::functions::lazy::cov, 2))?;
632
+ class.define_singleton_method("cov", function!(crate::functions::lazy::cov, 3))?;
560
633
  class.define_singleton_method(
561
634
  "arg_sort_by",
562
635
  function!(crate::functions::lazy::arg_sort_by, 2),
@@ -571,7 +644,7 @@ fn init() -> RbResult<()> {
571
644
  function!(crate::functions::lazy::concat_lst, 1),
572
645
  )?;
573
646
 
574
- let class = module.define_class("RbLazyFrame", Default::default())?;
647
+ let class = module.define_class("RbLazyFrame", ruby.class_object())?;
575
648
  class.define_singleton_method("read_json", function!(RbLazyFrame::read_json, 1))?;
576
649
  class.define_singleton_method(
577
650
  "new_from_ndjson",
@@ -580,7 +653,7 @@ fn init() -> RbResult<()> {
580
653
  class.define_singleton_method("new_from_csv", function!(RbLazyFrame::new_from_csv, -1))?;
581
654
  class.define_singleton_method(
582
655
  "new_from_parquet",
583
- function!(RbLazyFrame::new_from_parquet, 8),
656
+ function!(RbLazyFrame::new_from_parquet, 9),
584
657
  )?;
585
658
  class.define_singleton_method("new_from_ipc", function!(RbLazyFrame::new_from_ipc, 6))?;
586
659
  class.define_method("write_json", method!(RbLazyFrame::write_json, 1))?;
@@ -591,7 +664,7 @@ fn init() -> RbResult<()> {
591
664
  )?;
592
665
  class.define_method(
593
666
  "optimization_toggle",
594
- method!(RbLazyFrame::optimization_toggle, 7),
667
+ method!(RbLazyFrame::optimization_toggle, 8),
595
668
  )?;
596
669
  class.define_method("sort", method!(RbLazyFrame::sort, 4))?;
597
670
  class.define_method("sort_by_exprs", method!(RbLazyFrame::sort_by_exprs, 4))?;
@@ -601,17 +674,22 @@ fn init() -> RbResult<()> {
601
674
  class.define_method("fetch", method!(RbLazyFrame::fetch, 1))?;
602
675
  class.define_method("filter", method!(RbLazyFrame::filter, 1))?;
603
676
  class.define_method("select", method!(RbLazyFrame::select, 1))?;
604
- class.define_method("groupby", method!(RbLazyFrame::groupby, 2))?;
605
- class.define_method("groupby_rolling", method!(RbLazyFrame::groupby_rolling, 6))?;
606
- 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
+ )?;
607
686
  class.define_method("with_context", method!(RbLazyFrame::with_context, 1))?;
608
687
  class.define_method("join_asof", method!(RbLazyFrame::join_asof, 11))?;
609
688
  class.define_method("join", method!(RbLazyFrame::join, 7))?;
610
689
  class.define_method("with_columns", method!(RbLazyFrame::with_columns, 1))?;
611
690
  class.define_method("rename", method!(RbLazyFrame::rename, 2))?;
612
691
  class.define_method("reverse", method!(RbLazyFrame::reverse, 0))?;
613
- class.define_method("shift", method!(RbLazyFrame::shift, 1))?;
614
- class.define_method("shift_and_fill", method!(RbLazyFrame::shift_and_fill, 2))?;
692
+ class.define_method("shift", method!(RbLazyFrame::shift, 2))?;
615
693
  class.define_method("fill_nan", method!(RbLazyFrame::fill_nan, 1))?;
616
694
  class.define_method("min", method!(RbLazyFrame::min, 0))?;
617
695
  class.define_method("max", method!(RbLazyFrame::max, 0))?;
@@ -636,12 +714,12 @@ fn init() -> RbResult<()> {
636
714
  class.define_method("unnest", method!(RbLazyFrame::unnest, 1))?;
637
715
  class.define_method("width", method!(RbLazyFrame::width, 0))?;
638
716
 
639
- let class = module.define_class("RbLazyGroupBy", Default::default())?;
717
+ let class = module.define_class("RbLazyGroupBy", ruby.class_object())?;
640
718
  class.define_method("agg", method!(RbLazyGroupBy::agg, 1))?;
641
719
  class.define_method("head", method!(RbLazyGroupBy::head, 1))?;
642
720
  class.define_method("tail", method!(RbLazyGroupBy::tail, 1))?;
643
721
 
644
- let class = module.define_class("RbSeries", Default::default())?;
722
+ let class = module.define_class("RbSeries", ruby.class_object())?;
645
723
  class.define_singleton_method("new_opt_bool", function!(RbSeries::new_opt_bool, 3))?;
646
724
  class.define_singleton_method("new_opt_u8", function!(RbSeries::new_opt_u8, 3))?;
647
725
  class.define_singleton_method("new_opt_u16", function!(RbSeries::new_opt_u16, 3))?;
@@ -714,7 +792,7 @@ fn init() -> RbResult<()> {
714
792
  class.define_method("has_validity", method!(RbSeries::has_validity, 0))?;
715
793
  class.define_method("sample_n", method!(RbSeries::sample_n, 4))?;
716
794
  class.define_method("sample_frac", method!(RbSeries::sample_frac, 4))?;
717
- class.define_method("series_equal", method!(RbSeries::series_equal, 3))?;
795
+ class.define_method("equals", method!(RbSeries::equals, 3))?;
718
796
  class.define_method("eq", method!(RbSeries::eq, 1))?;
719
797
  class.define_method("neq", method!(RbSeries::neq, 1))?;
720
798
  class.define_method("gt", method!(RbSeries::gt, 1))?;
@@ -731,8 +809,6 @@ fn init() -> RbResult<()> {
731
809
  class.define_method("apply_lambda", method!(RbSeries::apply_lambda, 3))?;
732
810
  class.define_method("zip_with", method!(RbSeries::zip_with, 2))?;
733
811
  class.define_method("to_dummies", method!(RbSeries::to_dummies, 2))?;
734
- class.define_method("peak_max", method!(RbSeries::peak_max, 0))?;
735
- class.define_method("peak_min", method!(RbSeries::peak_min, 0))?;
736
812
  class.define_method("n_unique", method!(RbSeries::n_unique, 0))?;
737
813
  class.define_method("floor", method!(RbSeries::floor, 0))?;
738
814
  class.define_method("shrink_to_fit", method!(RbSeries::shrink_to_fit, 0))?;
@@ -741,7 +817,7 @@ fn init() -> RbResult<()> {
741
817
  class.define_method("kurtosis", method!(RbSeries::kurtosis, 2))?;
742
818
  class.define_method("cast", method!(RbSeries::cast, 2))?;
743
819
  class.define_method("time_unit", method!(RbSeries::time_unit, 0))?;
744
- class.define_method("set_at_idx", method!(RbSeries::set_at_idx, 2))?;
820
+ class.define_method("scatter", method!(RbSeries::scatter, 2))?;
745
821
 
746
822
  // set
747
823
  // class.define_method("set_with_mask_str", method!(RbSeries::set_with_mask_str, 2))?;
@@ -902,11 +978,19 @@ fn init() -> RbResult<()> {
902
978
  // extra
903
979
  class.define_method("extend_constant", method!(RbSeries::extend_constant, 2))?;
904
980
 
905
- let class = module.define_class("RbWhen", Default::default())?;
981
+ let class = module.define_class("RbWhen", ruby.class_object())?;
906
982
  class.define_method("_then", method!(RbWhen::then, 1))?;
907
983
 
908
- let class = module.define_class("RbWhenThen", Default::default())?;
909
- 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))?;
910
994
 
911
995
  Ok(())
912
996
  }