polars-df 0.21.0 → 0.22.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 (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/Cargo.lock +55 -48
  4. data/Cargo.toml +3 -0
  5. data/README.md +12 -0
  6. data/ext/polars/Cargo.toml +22 -11
  7. data/ext/polars/src/batched_csv.rs +4 -4
  8. data/ext/polars/src/catalog/unity.rs +96 -94
  9. data/ext/polars/src/conversion/any_value.rs +26 -30
  10. data/ext/polars/src/conversion/chunked_array.rs +32 -28
  11. data/ext/polars/src/conversion/datetime.rs +11 -0
  12. data/ext/polars/src/conversion/mod.rs +307 -34
  13. data/ext/polars/src/dataframe/construction.rs +4 -3
  14. data/ext/polars/src/dataframe/export.rs +17 -15
  15. data/ext/polars/src/dataframe/general.rs +15 -12
  16. data/ext/polars/src/dataframe/io.rs +1 -2
  17. data/ext/polars/src/dataframe/mod.rs +25 -1
  18. data/ext/polars/src/dataframe/serde.rs +23 -8
  19. data/ext/polars/src/exceptions.rs +8 -4
  20. data/ext/polars/src/expr/array.rs +73 -4
  21. data/ext/polars/src/expr/binary.rs +26 -1
  22. data/ext/polars/src/expr/bitwise.rs +39 -0
  23. data/ext/polars/src/expr/categorical.rs +20 -0
  24. data/ext/polars/src/expr/datatype.rs +24 -1
  25. data/ext/polars/src/expr/datetime.rs +58 -14
  26. data/ext/polars/src/expr/general.rs +87 -15
  27. data/ext/polars/src/expr/list.rs +32 -24
  28. data/ext/polars/src/expr/meta.rs +15 -6
  29. data/ext/polars/src/expr/mod.rs +3 -0
  30. data/ext/polars/src/expr/name.rs +19 -14
  31. data/ext/polars/src/expr/rolling.rs +20 -0
  32. data/ext/polars/src/expr/serde.rs +28 -0
  33. data/ext/polars/src/expr/string.rs +64 -10
  34. data/ext/polars/src/expr/struct.rs +9 -1
  35. data/ext/polars/src/file.rs +15 -9
  36. data/ext/polars/src/functions/business.rs +0 -1
  37. data/ext/polars/src/functions/io.rs +25 -3
  38. data/ext/polars/src/functions/lazy.rs +11 -6
  39. data/ext/polars/src/functions/meta.rs +3 -3
  40. data/ext/polars/src/functions/string_cache.rs +3 -3
  41. data/ext/polars/src/interop/arrow/to_ruby.rs +3 -3
  42. data/ext/polars/src/interop/numo/numo_rs.rs +4 -3
  43. data/ext/polars/src/io/mod.rs +6 -0
  44. data/ext/polars/src/lazyframe/general.rs +59 -9
  45. data/ext/polars/src/lazyframe/mod.rs +16 -1
  46. data/ext/polars/src/lazyframe/optflags.rs +58 -0
  47. data/ext/polars/src/lazyframe/serde.rs +27 -3
  48. data/ext/polars/src/lib.rs +261 -19
  49. data/ext/polars/src/map/dataframe.rs +20 -17
  50. data/ext/polars/src/map/lazy.rs +6 -5
  51. data/ext/polars/src/map/series.rs +8 -7
  52. data/ext/polars/src/on_startup.rs +12 -5
  53. data/ext/polars/src/rb_modules.rs +2 -2
  54. data/ext/polars/src/series/aggregation.rs +85 -28
  55. data/ext/polars/src/series/construction.rs +1 -0
  56. data/ext/polars/src/series/export.rs +37 -33
  57. data/ext/polars/src/series/general.rs +120 -21
  58. data/ext/polars/src/series/mod.rs +29 -4
  59. data/lib/polars/array_expr.rb +382 -3
  60. data/lib/polars/array_name_space.rb +281 -0
  61. data/lib/polars/binary_expr.rb +67 -0
  62. data/lib/polars/binary_name_space.rb +43 -0
  63. data/lib/polars/cat_expr.rb +224 -0
  64. data/lib/polars/cat_name_space.rb +138 -0
  65. data/lib/polars/config.rb +2 -2
  66. data/lib/polars/convert.rb +6 -6
  67. data/lib/polars/data_frame.rb +794 -27
  68. data/lib/polars/data_type_expr.rb +52 -0
  69. data/lib/polars/data_types.rb +26 -5
  70. data/lib/polars/date_time_expr.rb +252 -1
  71. data/lib/polars/date_time_name_space.rb +299 -0
  72. data/lib/polars/expr.rb +1248 -206
  73. data/lib/polars/functions/business.rb +95 -0
  74. data/lib/polars/functions/datatype.rb +21 -0
  75. data/lib/polars/functions/lazy.rb +14 -1
  76. data/lib/polars/io/csv.rb +1 -1
  77. data/lib/polars/io/iceberg.rb +27 -0
  78. data/lib/polars/io/json.rb +4 -4
  79. data/lib/polars/io/ndjson.rb +4 -4
  80. data/lib/polars/io/parquet.rb +32 -7
  81. data/lib/polars/io/scan_options.rb +4 -1
  82. data/lib/polars/lazy_frame.rb +1028 -28
  83. data/lib/polars/list_expr.rb +217 -17
  84. data/lib/polars/list_name_space.rb +231 -22
  85. data/lib/polars/meta_expr.rb +89 -0
  86. data/lib/polars/name_expr.rb +36 -0
  87. data/lib/polars/query_opt_flags.rb +50 -0
  88. data/lib/polars/scan_cast_options.rb +20 -1
  89. data/lib/polars/schema.rb +79 -3
  90. data/lib/polars/selector.rb +72 -0
  91. data/lib/polars/selectors.rb +3 -3
  92. data/lib/polars/series.rb +1053 -54
  93. data/lib/polars/string_expr.rb +436 -32
  94. data/lib/polars/string_name_space.rb +736 -50
  95. data/lib/polars/struct_expr.rb +103 -0
  96. data/lib/polars/struct_name_space.rb +19 -1
  97. data/lib/polars/utils/serde.rb +17 -0
  98. data/lib/polars/utils/various.rb +22 -1
  99. data/lib/polars/utils.rb +5 -1
  100. data/lib/polars/version.rb +1 -1
  101. data/lib/polars.rb +6 -0
  102. metadata +11 -1
@@ -28,14 +28,15 @@ use dataframe::RbDataFrame;
28
28
  use error::RbPolarsErr;
29
29
  use exceptions::{RbTypeError, RbValueError};
30
30
  use expr::RbExpr;
31
+ use expr::datatype::RbDataTypeExpr;
31
32
  use expr::rb_exprs_to_exprs;
32
33
  use expr::selector::RbSelector;
33
34
  use functions::string_cache::RbStringCacheHolder;
34
35
  use functions::whenthen::{RbChainedThen, RbChainedWhen, RbThen, RbWhen};
35
36
  use interop::arrow::to_ruby::RbArrowArrayStream;
36
- use lazyframe::RbLazyFrame;
37
+ use lazyframe::{RbLazyFrame, RbOptFlags};
37
38
  use lazygroupby::RbLazyGroupBy;
38
- use magnus::{Ruby, define_module, function, method, prelude::*};
39
+ use magnus::{Ruby, function, method, prelude::*};
39
40
  use series::RbSeries;
40
41
  use sql::RbSQLContext;
41
42
 
@@ -51,7 +52,7 @@ fn re_escape(pattern: String) -> String {
51
52
  fn init(ruby: &Ruby) -> RbResult<()> {
52
53
  crate::on_startup::register_startup_deps();
53
54
 
54
- let module = define_module("Polars")?;
55
+ let module = ruby.define_module("Polars")?;
55
56
 
56
57
  let class = module.define_class("RbBatchedCsv", ruby.class_object())?;
57
58
  class.define_singleton_method("new", function!(RbBatchedCsv::new, -1))?;
@@ -157,7 +158,14 @@ fn init(ruby: &Ruby) -> RbResult<()> {
157
158
  class.define_method("to_struct", method!(RbDataFrame::to_struct, 1))?;
158
159
  class.define_method("unnest", method!(RbDataFrame::unnest, 1))?;
159
160
  class.define_method("clear", method!(RbDataFrame::clear, 0))?;
160
- class.define_method("serialize_json", method!(RbDataFrame::serialize_json, 1))?;
161
+ class.define_method(
162
+ "serialize_binary",
163
+ method!(RbDataFrame::serialize_binary, 1),
164
+ )?;
165
+ class.define_singleton_method(
166
+ "deserialize_binary",
167
+ function!(RbDataFrame::deserialize_binary, 1),
168
+ )?;
161
169
 
162
170
  let class = module.define_class("RbExpr", ruby.class_object())?;
163
171
  class.define_method("+", method!(RbExpr::add, 1))?;
@@ -221,6 +229,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
221
229
  class.define_method("peak_max", method!(RbExpr::peak_max, 0))?;
222
230
  class.define_method("arg_max", method!(RbExpr::arg_max, 0))?;
223
231
  class.define_method("arg_min", method!(RbExpr::arg_min, 0))?;
232
+ class.define_method("index_of", method!(RbExpr::index_of, 1))?;
224
233
  class.define_method("search_sorted", method!(RbExpr::search_sorted, 3))?;
225
234
  class.define_method("gather", method!(RbExpr::gather, 1))?;
226
235
  class.define_method("get", method!(RbExpr::get, 1))?;
@@ -240,6 +249,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
240
249
  class.define_method("var", method!(RbExpr::var, 1))?;
241
250
  class.define_method("is_unique", method!(RbExpr::is_unique, 0))?;
242
251
  class.define_method("is_between", method!(RbExpr::is_between, 3))?;
252
+ class.define_method("is_close", method!(RbExpr::is_close, 4))?;
243
253
  class.define_method("approx_n_unique", method!(RbExpr::approx_n_unique, 0))?;
244
254
  class.define_method("is_first_distinct", method!(RbExpr::is_first_distinct, 0))?;
245
255
  class.define_method("is_last_distinct", method!(RbExpr::is_last_distinct, 0))?;
@@ -251,6 +261,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
251
261
  class.define_method("append", method!(RbExpr::append, 2))?;
252
262
  class.define_method("rechunk", method!(RbExpr::rechunk, 0))?;
253
263
  class.define_method("round", method!(RbExpr::round, 2))?;
264
+ class.define_method("round_sig_figs", method!(RbExpr::round_sig_figs, 1))?;
254
265
  class.define_method("floor", method!(RbExpr::floor, 0))?;
255
266
  class.define_method("ceil", method!(RbExpr::ceil, 0))?;
256
267
  class.define_method("clip", method!(RbExpr::clip, 2))?;
@@ -258,6 +269,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
258
269
  class.define_method("sin", method!(RbExpr::sin, 0))?;
259
270
  class.define_method("cos", method!(RbExpr::cos, 0))?;
260
271
  class.define_method("tan", method!(RbExpr::tan, 0))?;
272
+ class.define_method("cot", method!(RbExpr::cot, 0))?;
261
273
  class.define_method("arcsin", method!(RbExpr::arcsin, 0))?;
262
274
  class.define_method("arccos", method!(RbExpr::arccos, 0))?;
263
275
  class.define_method("arctan", method!(RbExpr::arctan, 0))?;
@@ -267,21 +279,25 @@ fn init(ruby: &Ruby) -> RbResult<()> {
267
279
  class.define_method("arcsinh", method!(RbExpr::arcsinh, 0))?;
268
280
  class.define_method("arccosh", method!(RbExpr::arccosh, 0))?;
269
281
  class.define_method("arctanh", method!(RbExpr::arctanh, 0))?;
282
+ class.define_method("degrees", method!(RbExpr::degrees, 0))?;
283
+ class.define_method("radians", method!(RbExpr::radians, 0))?;
270
284
  class.define_method("sign", method!(RbExpr::sign, 0))?;
271
285
  class.define_method("is_duplicated", method!(RbExpr::is_duplicated, 0))?;
272
286
  class.define_method("over", method!(RbExpr::over, 1))?;
273
- class.define_method("_and", method!(RbExpr::_and, 1))?;
274
- class.define_method("_xor", method!(RbExpr::_xor, 1))?;
275
- class.define_method("_or", method!(RbExpr::_or, 1))?;
287
+ class.define_method("rolling", method!(RbExpr::rolling, 4))?;
288
+ class.define_method("and_", method!(RbExpr::and_, 1))?;
289
+ class.define_method("or_", method!(RbExpr::or_, 1))?;
290
+ class.define_method("xor_", method!(RbExpr::xor_, 1))?;
276
291
  class.define_method("is_in", method!(RbExpr::is_in, 2))?;
277
292
  class.define_method("repeat_by", method!(RbExpr::repeat_by, 1))?;
278
293
  class.define_method("pow", method!(RbExpr::pow, 1))?;
294
+ class.define_method("sqrt", method!(RbExpr::sqrt, 0))?;
295
+ class.define_method("cbrt", method!(RbExpr::cbrt, 0))?;
279
296
  class.define_method("cum_sum", method!(RbExpr::cum_sum, 1))?;
280
297
  class.define_method("cum_max", method!(RbExpr::cum_max, 1))?;
281
298
  class.define_method("cum_min", method!(RbExpr::cum_min, 1))?;
282
299
  class.define_method("cum_prod", method!(RbExpr::cum_prod, 1))?;
283
300
  class.define_method("product", method!(RbExpr::product, 0))?;
284
- class.define_method("shrink_dtype", method!(RbExpr::shrink_dtype, 0))?;
285
301
  class.define_method("str_to_date", method!(RbExpr::str_to_date, 4))?;
286
302
  class.define_method("str_to_datetime", method!(RbExpr::str_to_datetime, 7))?;
287
303
  class.define_method("str_to_time", method!(RbExpr::str_to_time, 3))?;
@@ -297,6 +313,8 @@ fn init(ruby: &Ruby) -> RbResult<()> {
297
313
  class.define_method("str_strip_prefix", method!(RbExpr::str_strip_prefix, 1))?;
298
314
  class.define_method("str_strip_suffix", method!(RbExpr::str_strip_suffix, 1))?;
299
315
  class.define_method("str_slice", method!(RbExpr::str_slice, 2))?;
316
+ class.define_method("str_head", method!(RbExpr::str_head, 1))?;
317
+ class.define_method("str_tail", method!(RbExpr::str_tail, 1))?;
300
318
  class.define_method("str_to_uppercase", method!(RbExpr::str_to_uppercase, 0))?;
301
319
  class.define_method("str_to_lowercase", method!(RbExpr::str_to_lowercase, 0))?;
302
320
  // class.define_method("str_to_titlecase", method!(RbExpr::str_to_titlecase, 0))?;
@@ -304,17 +322,25 @@ fn init(ruby: &Ruby) -> RbResult<()> {
304
322
  class.define_method("str_len_chars", method!(RbExpr::str_len_chars, 0))?;
305
323
  class.define_method("str_replace_n", method!(RbExpr::str_replace_n, 4))?;
306
324
  class.define_method("str_replace_all", method!(RbExpr::str_replace_all, 3))?;
325
+ class.define_method("str_normalize", method!(RbExpr::str_normalize, 1))?;
307
326
  class.define_method("str_reverse", method!(RbExpr::str_reverse, 0))?;
308
327
  class.define_method("str_zfill", method!(RbExpr::str_zfill, 1))?;
309
328
  class.define_method("str_pad_start", method!(RbExpr::str_pad_start, 2))?;
310
329
  class.define_method("str_pad_end", method!(RbExpr::str_pad_end, 2))?;
311
330
  class.define_method("str_contains", method!(RbExpr::str_contains, 3))?;
331
+ class.define_method("str_find", method!(RbExpr::str_find, 3))?;
312
332
  class.define_method("str_ends_with", method!(RbExpr::str_ends_with, 1))?;
313
333
  class.define_method("str_starts_with", method!(RbExpr::str_starts_with, 1))?;
314
- class.define_method("array_max", method!(RbExpr::array_max, 0))?;
315
- class.define_method("array_min", method!(RbExpr::array_min, 0))?;
316
- class.define_method("array_sum", method!(RbExpr::array_sum, 0))?;
334
+ class.define_method("arr_len", method!(RbExpr::arr_len, 0))?;
335
+ class.define_method("arr_max", method!(RbExpr::arr_max, 0))?;
336
+ class.define_method("arr_min", method!(RbExpr::arr_min, 0))?;
337
+ class.define_method("arr_sum", method!(RbExpr::arr_sum, 0))?;
338
+ class.define_method("arr_std", method!(RbExpr::arr_std, 1))?;
339
+ class.define_method("arr_var", method!(RbExpr::arr_var, 1))?;
340
+ class.define_method("arr_mean", method!(RbExpr::arr_mean, 0))?;
341
+ class.define_method("arr_median", method!(RbExpr::arr_median, 0))?;
317
342
  class.define_method("arr_unique", method!(RbExpr::arr_unique, 1))?;
343
+ class.define_method("arr_n_unique", method!(RbExpr::arr_n_unique, 0))?;
318
344
  class.define_method("arr_to_list", method!(RbExpr::arr_to_list, 0))?;
319
345
  class.define_method("arr_all", method!(RbExpr::arr_all, 0))?;
320
346
  class.define_method("arr_any", method!(RbExpr::arr_any, 0))?;
@@ -326,6 +352,11 @@ fn init(ruby: &Ruby) -> RbResult<()> {
326
352
  class.define_method("arr_join", method!(RbExpr::arr_join, 2))?;
327
353
  class.define_method("arr_contains", method!(RbExpr::arr_contains, 2))?;
328
354
  class.define_method("arr_count_matches", method!(RbExpr::arr_count_matches, 1))?;
355
+ class.define_method("arr_to_struct", method!(RbExpr::arr_to_struct, 1))?;
356
+ class.define_method("arr_slice", method!(RbExpr::arr_slice, 3))?;
357
+ class.define_method("arr_tail", method!(RbExpr::arr_tail, 2))?;
358
+ class.define_method("arr_shift", method!(RbExpr::arr_shift, 1))?;
359
+ class.define_method("arr_explode", method!(RbExpr::arr_explode, 0))?;
329
360
  class.define_method("binary_contains", method!(RbExpr::bin_contains, 1))?;
330
361
  class.define_method("binary_ends_with", method!(RbExpr::bin_ends_with, 1))?;
331
362
  class.define_method("binary_starts_with", method!(RbExpr::bin_starts_with, 1))?;
@@ -334,7 +365,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
334
365
  class.define_method("str_base64_encode", method!(RbExpr::str_base64_encode, 0))?;
335
366
  class.define_method("str_base64_decode", method!(RbExpr::str_base64_decode, 1))?;
336
367
  class.define_method("str_to_integer", method!(RbExpr::str_to_integer, 3))?;
337
- class.define_method("str_json_decode", method!(RbExpr::str_json_decode, 2))?;
368
+ class.define_method("str_json_decode", method!(RbExpr::str_json_decode, 1))?;
338
369
  class.define_method("binary_hex_encode", method!(RbExpr::bin_hex_encode, 0))?;
339
370
  class.define_method("binary_hex_decode", method!(RbExpr::bin_hex_decode, 1))?;
340
371
  class.define_method(
@@ -345,6 +376,8 @@ fn init(ruby: &Ruby) -> RbResult<()> {
345
376
  "binary_base64_decode",
346
377
  method!(RbExpr::bin_base64_decode, 1),
347
378
  )?;
379
+ class.define_method("bin_reinterpret", method!(RbExpr::bin_reinterpret, 2))?;
380
+ class.define_method("bin_size_bytes", method!(RbExpr::bin_size_bytes, 0))?;
348
381
  class.define_method(
349
382
  "str_json_path_match",
350
383
  method!(RbExpr::str_json_path_match, 1),
@@ -353,7 +386,6 @@ fn init(ruby: &Ruby) -> RbResult<()> {
353
386
  class.define_method("str_extract_all", method!(RbExpr::str_extract_all, 1))?;
354
387
  class.define_method("str_extract_groups", method!(RbExpr::str_extract_groups, 1))?;
355
388
  class.define_method("str_count_matches", method!(RbExpr::str_count_matches, 2))?;
356
- class.define_method("strftime", method!(RbExpr::dt_to_string, 1))?;
357
389
  class.define_method("str_split", method!(RbExpr::str_split, 1))?;
358
390
  class.define_method(
359
391
  "str_split_inclusive",
@@ -368,10 +400,21 @@ fn init(ruby: &Ruby) -> RbResult<()> {
368
400
  class.define_method("str_to_decimal", method!(RbExpr::str_to_decimal, 1))?;
369
401
  class.define_method("str_contains_any", method!(RbExpr::str_contains_any, 2))?;
370
402
  class.define_method("str_replace_many", method!(RbExpr::str_replace_many, 3))?;
403
+ class.define_method("str_extract_many", method!(RbExpr::str_extract_many, 3))?;
404
+ class.define_method("str_find_many", method!(RbExpr::str_find_many, 3))?;
405
+ class.define_method("str_escape_regex", method!(RbExpr::str_escape_regex, 0))?;
371
406
  class.define_method("list_len", method!(RbExpr::list_len, 0))?;
372
407
  class.define_method("list_contains", method!(RbExpr::list_contains, 2))?;
373
408
  class.define_method("list_count_matches", method!(RbExpr::list_count_matches, 1))?;
409
+ class.define_method(
410
+ "dt_add_business_days",
411
+ method!(RbExpr::dt_add_business_days, 4),
412
+ )?;
413
+ class.define_method("strftime", method!(RbExpr::dt_to_string, 1))?;
414
+ class.define_method("dt_millennium", method!(RbExpr::dt_millennium, 0))?;
415
+ class.define_method("dt_century", method!(RbExpr::dt_century, 0))?;
374
416
  class.define_method("dt_year", method!(RbExpr::dt_year, 0))?;
417
+ class.define_method("dt_is_business_day", method!(RbExpr::dt_is_business_day, 2))?;
375
418
  class.define_method("dt_is_leap_year", method!(RbExpr::dt_is_leap_year, 0))?;
376
419
  class.define_method("dt_iso_year", method!(RbExpr::dt_iso_year, 0))?;
377
420
  class.define_method("dt_quarter", method!(RbExpr::dt_quarter, 0))?;
@@ -408,7 +451,6 @@ fn init(ruby: &Ruby) -> RbResult<()> {
408
451
  class.define_method("dt_timestamp", method!(RbExpr::dt_timestamp, 1))?;
409
452
  class.define_method("dt_to_string", method!(RbExpr::dt_to_string, 1))?;
410
453
  class.define_method("dt_offset_by", method!(RbExpr::dt_offset_by, 1))?;
411
- class.define_method("dt_epoch_seconds", method!(RbExpr::dt_epoch_seconds, 0))?;
412
454
  class.define_method("dt_with_time_unit", method!(RbExpr::dt_with_time_unit, 1))?;
413
455
  class.define_method(
414
456
  "dt_convert_time_zone",
@@ -425,6 +467,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
425
467
  class.define_method("dt_base_utc_offset", method!(RbExpr::dt_base_utc_offset, 0))?;
426
468
  class.define_method("dt_dst_offset", method!(RbExpr::dt_dst_offset, 0))?;
427
469
  class.define_method("dt_round", method!(RbExpr::dt_round, 1))?;
470
+ class.define_method("dt_replace", method!(RbExpr::dt_replace, 8))?;
428
471
  class.define_method("dt_combine", method!(RbExpr::dt_combine, 2))?;
429
472
  class.define_method("map_batches", method!(RbExpr::map_batches, 5))?;
430
473
  class.define_method("dot", method!(RbExpr::dot, 1))?;
@@ -452,6 +495,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
452
495
  method!(RbExpr::rolling_quantile_by, 6),
453
496
  )?;
454
497
  class.define_method("rolling_skew", method!(RbExpr::rolling_skew, 4))?;
498
+ class.define_method("rolling_kurtosis", method!(RbExpr::rolling_kurtosis, 5))?;
455
499
  class.define_method("lower_bound", method!(RbExpr::lower_bound, 0))?;
456
500
  class.define_method("upper_bound", method!(RbExpr::upper_bound, 0))?;
457
501
  class.define_method("list_max", method!(RbExpr::list_max, 0))?;
@@ -464,11 +508,16 @@ fn init(ruby: &Ruby) -> RbResult<()> {
464
508
  method!(RbExpr::list_sample_fraction, 4),
465
509
  )?;
466
510
  class.define_method("list_gather", method!(RbExpr::list_gather, 2))?;
511
+ class.define_method("list_gather_every", method!(RbExpr::list_gather_every, 2))?;
467
512
  class.define_method("list_to_array", method!(RbExpr::list_to_array, 1))?;
468
513
  class.define_method("list_mean", method!(RbExpr::list_mean, 0))?;
514
+ class.define_method("list_median", method!(RbExpr::list_median, 0))?;
515
+ class.define_method("list_std", method!(RbExpr::list_std, 1))?;
516
+ class.define_method("list_var", method!(RbExpr::list_var, 1))?;
469
517
  class.define_method("list_tail", method!(RbExpr::list_tail, 1))?;
470
518
  class.define_method("list_sort", method!(RbExpr::list_sort, 2))?;
471
519
  class.define_method("list_reverse", method!(RbExpr::list_reverse, 0))?;
520
+ class.define_method("list_n_unique", method!(RbExpr::list_n_unique, 0))?;
472
521
  class.define_method("list_unique", method!(RbExpr::list_unique, 1))?;
473
522
  class.define_method("list_set_operation", method!(RbExpr::list_set_operation, 2))?;
474
523
  class.define_method("list_get", method!(RbExpr::list_get, 2))?;
@@ -483,7 +532,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
483
532
  class.define_method("list_eval", method!(RbExpr::list_eval, 1))?;
484
533
  class.define_method("list_filter", method!(RbExpr::list_filter, 1))?;
485
534
  class.define_method("cumulative_eval", method!(RbExpr::cumulative_eval, 2))?;
486
- class.define_method("list_to_struct", method!(RbExpr::list_to_struct, 3))?;
535
+ class.define_method("list_to_struct", method!(RbExpr::list_to_struct, 1))?;
487
536
  class.define_method("rank", method!(RbExpr::rank, 3))?;
488
537
  class.define_method("diff", method!(RbExpr::diff, 2))?;
489
538
  class.define_method("pct_change", method!(RbExpr::pct_change, 1))?;
@@ -491,6 +540,11 @@ fn init(ruby: &Ruby) -> RbResult<()> {
491
540
  class.define_method("kurtosis", method!(RbExpr::kurtosis, 2))?;
492
541
  class.define_method("str_join", method!(RbExpr::str_join, 2))?;
493
542
  class.define_method("cat_get_categories", method!(RbExpr::cat_get_categories, 0))?;
543
+ class.define_method("cat_len_bytes", method!(RbExpr::cat_len_bytes, 0))?;
544
+ class.define_method("cat_len_chars", method!(RbExpr::cat_len_chars, 0))?;
545
+ class.define_method("cat_starts_with", method!(RbExpr::cat_starts_with, 1))?;
546
+ class.define_method("cat_ends_with", method!(RbExpr::cat_ends_with, 1))?;
547
+ class.define_method("cat_slice", method!(RbExpr::cat_slice, 2))?;
494
548
  class.define_method("reshape", method!(RbExpr::reshape, 1))?;
495
549
  class.define_method("cum_count", method!(RbExpr::cum_count, 1))?;
496
550
  class.define_method("to_physical", method!(RbExpr::to_physical, 0))?;
@@ -498,6 +552,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
498
552
  class.define_method("sample_n", method!(RbExpr::sample_n, 4))?;
499
553
  class.define_method("sample_frac", method!(RbExpr::sample_frac, 4))?;
500
554
  class.define_method("ewm_mean", method!(RbExpr::ewm_mean, 4))?;
555
+ class.define_method("ewm_mean_by", method!(RbExpr::ewm_mean_by, 2))?;
501
556
  class.define_method("ewm_std", method!(RbExpr::ewm_std, 5))?;
502
557
  class.define_method("ewm_var", method!(RbExpr::ewm_var, 5))?;
503
558
  class.define_method("extend_constant", method!(RbExpr::extend_constant, 2))?;
@@ -516,15 +571,51 @@ fn init(ruby: &Ruby) -> RbResult<()> {
516
571
  method!(RbExpr::struct_rename_fields, 1),
517
572
  )?;
518
573
  class.define_method("struct_json_encode", method!(RbExpr::struct_json_encode, 0))?;
574
+ class.define_method("struct_with_fields", method!(RbExpr::struct_with_fields, 1))?;
519
575
  class.define_method("log", method!(RbExpr::log, 1))?;
576
+ class.define_method("log1p", method!(RbExpr::log1p, 0))?;
520
577
  class.define_method("exp", method!(RbExpr::exp, 0))?;
521
578
  class.define_method("entropy", method!(RbExpr::entropy, 2))?;
522
579
  class.define_method("_hash", method!(RbExpr::hash, 4))?;
523
580
  class.define_method("set_sorted_flag", method!(RbExpr::set_sorted_flag, 1))?;
524
581
  class.define_method("replace", method!(RbExpr::replace, 2))?;
525
582
  class.define_method("replace_strict", method!(RbExpr::replace_strict, 4))?;
583
+ class.define_method("hist", method!(RbExpr::hist, 4))?;
526
584
  class.define_method("into_selector", method!(RbExpr::into_selector, 0))?;
527
585
  class.define_singleton_method("new_selector", function!(RbExpr::new_selector, 1))?;
586
+ #[cfg(feature = "serialize_binary")]
587
+ class.define_method("serialize_binary", method!(RbExpr::serialize_binary, 1))?;
588
+ #[cfg(feature = "serialize_binary")]
589
+ class.define_singleton_method(
590
+ "deserialize_binary",
591
+ function!(RbExpr::deserialize_binary, 1),
592
+ )?;
593
+
594
+ // bitwise
595
+ class.define_method("bitwise_count_ones", method!(RbExpr::bitwise_count_ones, 0))?;
596
+ class.define_method(
597
+ "bitwise_count_zeros",
598
+ method!(RbExpr::bitwise_count_zeros, 0),
599
+ )?;
600
+ class.define_method(
601
+ "bitwise_leading_ones",
602
+ method!(RbExpr::bitwise_leading_ones, 0),
603
+ )?;
604
+ class.define_method(
605
+ "bitwise_leading_zeros",
606
+ method!(RbExpr::bitwise_leading_zeros, 0),
607
+ )?;
608
+ class.define_method(
609
+ "bitwise_trailing_ones",
610
+ method!(RbExpr::bitwise_trailing_ones, 0),
611
+ )?;
612
+ class.define_method(
613
+ "bitwise_trailing_zeros",
614
+ method!(RbExpr::bitwise_trailing_zeros, 0),
615
+ )?;
616
+ class.define_method("bitwise_and", method!(RbExpr::bitwise_and, 0))?;
617
+ class.define_method("bitwise_or", method!(RbExpr::bitwise_or, 0))?;
618
+ class.define_method("bitwise_xor", method!(RbExpr::bitwise_xor, 0))?;
528
619
 
529
620
  // meta
530
621
  class.define_method("meta_pop", method!(RbExpr::meta_pop, 1))?;
@@ -541,6 +632,11 @@ fn init(ruby: &Ruby) -> RbResult<()> {
541
632
  "meta_is_regex_projection",
542
633
  method!(RbExpr::meta_is_regex_projection, 0),
543
634
  )?;
635
+ class.define_method(
636
+ "meta_is_column_selection",
637
+ method!(RbExpr::meta_is_column_selection, 1),
638
+ )?;
639
+ class.define_method("meta_is_literal", method!(RbExpr::meta_is_literal, 1))?;
544
640
  class.define_method("meta_tree_format", method!(RbExpr::meta_tree_format, 1))?;
545
641
 
546
642
  // name
@@ -550,6 +646,8 @@ fn init(ruby: &Ruby) -> RbResult<()> {
550
646
  class.define_method("name_suffix", method!(RbExpr::name_suffix, 1))?;
551
647
  class.define_method("name_to_lowercase", method!(RbExpr::name_to_lowercase, 0))?;
552
648
  class.define_method("name_to_uppercase", method!(RbExpr::name_to_uppercase, 0))?;
649
+ class.define_method("name_prefix_fields", method!(RbExpr::name_prefix_fields, 1))?;
650
+ class.define_method("name_suffix_fields", method!(RbExpr::name_suffix_fields, 1))?;
553
651
 
554
652
  // maybe add to different class
555
653
  let class = module.define_module("Plr")?;
@@ -605,6 +703,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
605
703
  function!(functions::aggregation::mean_horizontal, 2),
606
704
  )?;
607
705
  class.define_singleton_method("as_struct", function!(functions::lazy::as_struct, 1))?;
706
+ class.define_singleton_method("field", function!(functions::lazy::field, 1))?;
608
707
  class.define_singleton_method("coalesce", function!(functions::lazy::coalesce, 1))?;
609
708
  class.define_singleton_method("arg_where", function!(functions::lazy::arg_where, 1))?;
610
709
  class.define_singleton_method(
@@ -631,6 +730,10 @@ fn init(ruby: &Ruby) -> RbResult<()> {
631
730
  )?;
632
731
  class.define_singleton_method("duration", function!(functions::lazy::duration, 9))?;
633
732
  class.define_singleton_method("ipc_schema", function!(functions::io::read_ipc_schema, 1))?;
733
+ class.define_singleton_method(
734
+ "read_parquet_metadata",
735
+ function!(functions::io::read_parquet_metadata, 1),
736
+ )?;
634
737
  class.define_singleton_method(
635
738
  "parquet_schema",
636
739
  function!(functions::io::read_parquet_schema, 1),
@@ -719,7 +822,20 @@ fn init(ruby: &Ruby) -> RbResult<()> {
719
822
  class.define_singleton_method("re_escape", function!(re_escape, 1))?;
720
823
 
721
824
  let class = module.define_class("RbLazyFrame", ruby.class_object())?;
722
- class.define_singleton_method("read_json", function!(RbLazyFrame::read_json, 1))?;
825
+ #[cfg(feature = "serialize_binary")]
826
+ class.define_method(
827
+ "serialize_binary",
828
+ method!(RbLazyFrame::serialize_binary, 1),
829
+ )?;
830
+ #[cfg(feature = "serialize_binary")]
831
+ class.define_singleton_method(
832
+ "deserialize_binary",
833
+ function!(RbLazyFrame::deserialize_binary, 1),
834
+ )?;
835
+ class.define_singleton_method(
836
+ "deserialize_json",
837
+ function!(RbLazyFrame::deserialize_json, 1),
838
+ )?;
723
839
  class.define_singleton_method(
724
840
  "new_from_ndjson",
725
841
  function!(RbLazyFrame::new_from_ndjson, 8),
@@ -742,6 +858,8 @@ fn init(ruby: &Ruby) -> RbResult<()> {
742
858
  )?;
743
859
  class.define_method("sort", method!(RbLazyFrame::sort, 5))?;
744
860
  class.define_method("sort_by_exprs", method!(RbLazyFrame::sort_by_exprs, 5))?;
861
+ class.define_method("top_k", method!(RbLazyFrame::top_k, 3))?;
862
+ class.define_method("bottom_k", method!(RbLazyFrame::bottom_k, 3))?;
745
863
  class.define_method("cache", method!(RbLazyFrame::cache, 0))?;
746
864
  class.define_method("collect", method!(RbLazyFrame::collect, 0))?;
747
865
  class.define_method("sink_parquet", method!(RbLazyFrame::sink_parquet, 9))?;
@@ -749,6 +867,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
749
867
  class.define_method("sink_csv", method!(RbLazyFrame::sink_csv, -1))?;
750
868
  class.define_method("sink_json", method!(RbLazyFrame::sink_json, 4))?;
751
869
  class.define_method("filter", method!(RbLazyFrame::filter, 1))?;
870
+ class.define_method("remove", method!(RbLazyFrame::remove, 1))?;
752
871
  class.define_method("select", method!(RbLazyFrame::select, 1))?;
753
872
  class.define_method("select_seq", method!(RbLazyFrame::select_seq, 1))?;
754
873
  class.define_method("group_by", method!(RbLazyFrame::group_by, 2))?;
@@ -760,6 +879,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
760
879
  class.define_method("with_context", method!(RbLazyFrame::with_context, 1))?;
761
880
  class.define_method("join_asof", method!(RbLazyFrame::join_asof, 14))?;
762
881
  class.define_method("join", method!(RbLazyFrame::join, 11))?;
882
+ class.define_method("join_where", method!(RbLazyFrame::join_where, 3))?;
763
883
  class.define_method("with_column", method!(RbLazyFrame::with_column, 1))?;
764
884
  class.define_method("with_columns", method!(RbLazyFrame::with_columns, 1))?;
765
885
  class.define_method(
@@ -781,6 +901,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
781
901
  class.define_method("explode", method!(RbLazyFrame::explode, 1))?;
782
902
  class.define_method("null_count", method!(RbLazyFrame::null_count, 0))?;
783
903
  class.define_method("unique", method!(RbLazyFrame::unique, 3))?;
904
+ class.define_method("drop_nans", method!(RbLazyFrame::drop_nans, 1))?;
784
905
  class.define_method("drop_nulls", method!(RbLazyFrame::drop_nulls, 1))?;
785
906
  class.define_method("slice", method!(RbLazyFrame::slice, 2))?;
786
907
  class.define_method("tail", method!(RbLazyFrame::tail, 1))?;
@@ -810,6 +931,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
810
931
  class.define_singleton_method("new_opt_i16", function!(RbSeries::new_opt_i16, 3))?;
811
932
  class.define_singleton_method("new_opt_i32", function!(RbSeries::new_opt_i32, 3))?;
812
933
  class.define_singleton_method("new_opt_i64", function!(RbSeries::new_opt_i64, 3))?;
934
+ class.define_singleton_method("new_opt_i128", function!(RbSeries::new_opt_i128, 3))?;
813
935
  class.define_singleton_method("new_opt_f32", function!(RbSeries::new_opt_f32, 3))?;
814
936
  class.define_singleton_method("new_opt_f64", function!(RbSeries::new_opt_f64, 3))?;
815
937
  class.define_singleton_method(
@@ -855,7 +977,8 @@ fn init(ruby: &Ruby) -> RbResult<()> {
855
977
  class.define_method("estimated_size", method!(RbSeries::estimated_size, 0))?;
856
978
  class.define_method("get_fmt", method!(RbSeries::get_fmt, 2))?;
857
979
  class.define_method("rechunk", method!(RbSeries::rechunk, 1))?;
858
- class.define_method("get_idx", method!(RbSeries::get_idx, 1))?;
980
+ class.define_method("get_index", method!(RbSeries::get_index, 1))?;
981
+ class.define_method("get_index_signed", method!(RbSeries::get_index_signed, 1))?;
859
982
  class.define_method("bitand", method!(RbSeries::bitand, 1))?;
860
983
  class.define_method("bitor", method!(RbSeries::bitor, 1))?;
861
984
  class.define_method("bitxor", method!(RbSeries::bitxor, 1))?;
@@ -869,6 +992,12 @@ fn init(ruby: &Ruby) -> RbResult<()> {
869
992
  class.define_method("max", method!(RbSeries::max, 0))?;
870
993
  class.define_method("min", method!(RbSeries::min, 0))?;
871
994
  class.define_method("sum", method!(RbSeries::sum, 0))?;
995
+ class.define_method("first", method!(RbSeries::first, 0))?;
996
+ class.define_method("last", method!(RbSeries::last, 0))?;
997
+ class.define_method("approx_n_unique", method!(RbSeries::approx_n_unique, 0))?;
998
+ class.define_method("bitwise_and", method!(RbSeries::bitwise_and, 0))?;
999
+ class.define_method("bitwise_or", method!(RbSeries::bitwise_or, 0))?;
1000
+ class.define_method("bitwise_xor", method!(RbSeries::bitwise_xor, 0))?;
872
1001
  class.define_method("n_chunks", method!(RbSeries::n_chunks, 0))?;
873
1002
  class.define_method("append", method!(RbSeries::append, 1))?;
874
1003
  class.define_method("extend", method!(RbSeries::extend, 1))?;
@@ -898,7 +1027,13 @@ fn init(ruby: &Ruby) -> RbResult<()> {
898
1027
  class.define_method("gt_eq", method!(RbSeries::gt_eq, 1))?;
899
1028
  class.define_method("lt", method!(RbSeries::lt, 1))?;
900
1029
  class.define_method("lt_eq", method!(RbSeries::lt_eq, 1))?;
901
- class.define_method("not", method!(RbSeries::not, 0))?;
1030
+ class.define_method("not_", method!(RbSeries::not_, 0))?;
1031
+ class.define_method("shrink_dtype", method!(RbSeries::shrink_dtype, 0))?;
1032
+ class.define_method(
1033
+ "str_to_decimal_infer",
1034
+ method!(RbSeries::str_to_decimal_infer, 1),
1035
+ )?;
1036
+ class.define_method("str_json_decode", method!(RbSeries::str_json_decode, 1))?;
902
1037
  class.define_method("to_s", method!(RbSeries::to_s, 0))?;
903
1038
  class.define_method("len", method!(RbSeries::len, 0))?;
904
1039
  class.define_method("to_a", method!(RbSeries::to_a, 0))?;
@@ -915,6 +1050,9 @@ fn init(ruby: &Ruby) -> RbResult<()> {
915
1050
  class.define_method("skew", method!(RbSeries::skew, 1))?;
916
1051
  class.define_method("kurtosis", method!(RbSeries::kurtosis, 2))?;
917
1052
  class.define_method("cast", method!(RbSeries::cast, 2))?;
1053
+ class.define_method("get_chunks", method!(RbSeries::get_chunks, 0))?;
1054
+ class.define_method("is_sorted", method!(RbSeries::is_sorted, 2))?;
1055
+ class.define_method("clear", method!(RbSeries::clear, 0))?;
918
1056
  class.define_method("time_unit", method!(RbSeries::time_unit, 0))?;
919
1057
  class.define_method("scatter", method!(RbSeries::scatter, 2))?;
920
1058
 
@@ -1152,7 +1290,10 @@ fn init(ruby: &Ruby) -> RbResult<()> {
1152
1290
  )?;
1153
1291
 
1154
1292
  // data type expr
1155
- let _class = module.define_class("RbDataTypeExpr", ruby.class_object())?;
1293
+ let class = module.define_class("RbDataTypeExpr", ruby.class_object())?;
1294
+ class.define_singleton_method("from_dtype", function!(RbDataTypeExpr::from_dtype, 1))?;
1295
+ class.define_singleton_method("of_expr", function!(RbDataTypeExpr::of_expr, 1))?;
1296
+ class.define_method("collect_dtype", method!(RbDataTypeExpr::collect_dtype, 1))?;
1156
1297
 
1157
1298
  // selector
1158
1299
  let class = module.define_class("RbSelector", ruby.class_object())?;
@@ -1189,5 +1330,106 @@ fn init(ruby: &Ruby) -> RbResult<()> {
1189
1330
  class.define_singleton_method("all", function!(RbSelector::all, 0))?;
1190
1331
  class.define_method("_hash", method!(RbSelector::hash, 0))?;
1191
1332
 
1333
+ // opt flags
1334
+ let class = module.define_class("RbOptFlags", ruby.class_object())?;
1335
+ class.define_singleton_method("empty", function!(RbOptFlags::empty, 0))?;
1336
+ class.define_singleton_method("default", function!(RbOptFlags::default, 0))?;
1337
+ class.define_method("no_optimizations", method!(RbOptFlags::no_optimizations, 0))?;
1338
+ class.define_method("copy", method!(RbOptFlags::copy, 0))?;
1339
+ class.define_method(
1340
+ "get_type_coercion",
1341
+ method!(RbOptFlags::get_type_coercion, 0),
1342
+ )?;
1343
+ class.define_method(
1344
+ "set_type_coercion",
1345
+ method!(RbOptFlags::set_type_coercion, 1),
1346
+ )?;
1347
+ class.define_method("get_type_check", method!(RbOptFlags::get_type_check, 0))?;
1348
+ class.define_method("set_type_check", method!(RbOptFlags::set_type_check, 1))?;
1349
+ class.define_method(
1350
+ "get_projection_pushdown",
1351
+ method!(RbOptFlags::get_projection_pushdown, 0),
1352
+ )?;
1353
+ class.define_method(
1354
+ "set_projection_pushdown",
1355
+ method!(RbOptFlags::set_projection_pushdown, 1),
1356
+ )?;
1357
+ class.define_method(
1358
+ "get_predicate_pushdown",
1359
+ method!(RbOptFlags::get_predicate_pushdown, 0),
1360
+ )?;
1361
+ class.define_method(
1362
+ "set_predicate_pushdown",
1363
+ method!(RbOptFlags::set_predicate_pushdown, 1),
1364
+ )?;
1365
+ class.define_method(
1366
+ "get_cluster_with_columns",
1367
+ method!(RbOptFlags::get_cluster_with_columns, 0),
1368
+ )?;
1369
+ class.define_method(
1370
+ "set_cluster_with_columns",
1371
+ method!(RbOptFlags::set_cluster_with_columns, 1),
1372
+ )?;
1373
+ class.define_method(
1374
+ "get_simplify_expression",
1375
+ method!(RbOptFlags::get_simplify_expression, 0),
1376
+ )?;
1377
+ class.define_method(
1378
+ "set_simplify_expression",
1379
+ method!(RbOptFlags::set_simplify_expression, 1),
1380
+ )?;
1381
+ class.define_method(
1382
+ "get_slice_pushdown",
1383
+ method!(RbOptFlags::get_slice_pushdown, 0),
1384
+ )?;
1385
+ class.define_method(
1386
+ "set_slice_pushdown",
1387
+ method!(RbOptFlags::set_slice_pushdown, 1),
1388
+ )?;
1389
+ class.define_method(
1390
+ "get_comm_subplan_elim",
1391
+ method!(RbOptFlags::get_comm_subplan_elim, 0),
1392
+ )?;
1393
+ class.define_method(
1394
+ "set_comm_subplan_elim",
1395
+ method!(RbOptFlags::set_comm_subplan_elim, 1),
1396
+ )?;
1397
+ class.define_method(
1398
+ "get_comm_subexpr_elim",
1399
+ method!(RbOptFlags::get_comm_subexpr_elim, 0),
1400
+ )?;
1401
+ class.define_method(
1402
+ "set_comm_subexpr_elim",
1403
+ method!(RbOptFlags::set_comm_subexpr_elim, 1),
1404
+ )?;
1405
+ class.define_method(
1406
+ "get_collapse_joins",
1407
+ method!(RbOptFlags::get_collapse_joins, 0),
1408
+ )?;
1409
+ class.define_method(
1410
+ "set_collapse_joins",
1411
+ method!(RbOptFlags::set_collapse_joins, 1),
1412
+ )?;
1413
+ class.define_method(
1414
+ "get_check_order_observe",
1415
+ method!(RbOptFlags::get_check_order_observe, 0),
1416
+ )?;
1417
+ class.define_method(
1418
+ "set_check_order_observe",
1419
+ method!(RbOptFlags::set_check_order_observe, 1),
1420
+ )?;
1421
+ class.define_method(
1422
+ "get_fast_projection",
1423
+ method!(RbOptFlags::get_fast_projection, 0),
1424
+ )?;
1425
+ class.define_method(
1426
+ "set_fast_projection",
1427
+ method!(RbOptFlags::set_fast_projection, 1),
1428
+ )?;
1429
+ class.define_method("get_eager", method!(RbOptFlags::get_eager, 0))?;
1430
+ class.define_method("set_eager", method!(RbOptFlags::set_eager, 1))?;
1431
+ class.define_method("get_streaming", method!(RbOptFlags::get_streaming, 0))?;
1432
+ class.define_method("set_streaming", method!(RbOptFlags::set_streaming, 1))?;
1433
+
1192
1434
  Ok(())
1193
1435
  }