polars-df 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -1
- data/Cargo.lock +107 -59
- data/Cargo.toml +0 -3
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/ext/polars/Cargo.toml +15 -7
- data/ext/polars/src/batched_csv.rs +4 -4
- data/ext/polars/src/conversion/anyvalue.rs +185 -0
- data/ext/polars/src/conversion/chunked_array.rs +140 -0
- data/ext/polars/src/{conversion.rs → conversion/mod.rs} +260 -340
- data/ext/polars/src/dataframe.rs +69 -53
- data/ext/polars/src/expr/array.rs +74 -0
- data/ext/polars/src/expr/datetime.rs +22 -56
- data/ext/polars/src/expr/general.rs +61 -33
- data/ext/polars/src/expr/list.rs +52 -4
- data/ext/polars/src/expr/meta.rs +48 -0
- data/ext/polars/src/expr/rolling.rs +1 -0
- data/ext/polars/src/expr/string.rs +59 -8
- data/ext/polars/src/expr/struct.rs +8 -4
- data/ext/polars/src/functions/aggregation.rs +6 -0
- data/ext/polars/src/functions/lazy.rs +103 -48
- data/ext/polars/src/functions/meta.rs +45 -1
- data/ext/polars/src/functions/string_cache.rs +14 -0
- data/ext/polars/src/{lazyframe.rs → lazyframe/mod.rs} +138 -22
- data/ext/polars/src/lib.rs +226 -168
- data/ext/polars/src/series/aggregation.rs +20 -0
- data/ext/polars/src/series/mod.rs +25 -4
- data/lib/polars/array_expr.rb +449 -0
- data/lib/polars/array_name_space.rb +346 -0
- data/lib/polars/cat_expr.rb +24 -0
- data/lib/polars/cat_name_space.rb +75 -0
- data/lib/polars/config.rb +2 -2
- data/lib/polars/data_frame.rb +179 -43
- data/lib/polars/data_types.rb +191 -28
- data/lib/polars/date_time_expr.rb +31 -14
- data/lib/polars/exceptions.rb +12 -1
- data/lib/polars/expr.rb +866 -186
- data/lib/polars/functions/aggregation/horizontal.rb +246 -0
- data/lib/polars/functions/aggregation/vertical.rb +282 -0
- data/lib/polars/functions/as_datatype.rb +248 -0
- data/lib/polars/functions/col.rb +47 -0
- data/lib/polars/functions/eager.rb +182 -0
- data/lib/polars/functions/lazy.rb +1280 -0
- data/lib/polars/functions/len.rb +49 -0
- data/lib/polars/functions/lit.rb +35 -0
- data/lib/polars/functions/random.rb +16 -0
- data/lib/polars/functions/range/date_range.rb +103 -0
- data/lib/polars/functions/range/int_range.rb +51 -0
- data/lib/polars/functions/repeat.rb +144 -0
- data/lib/polars/functions/whenthen.rb +27 -0
- data/lib/polars/functions.rb +29 -416
- data/lib/polars/group_by.rb +2 -2
- data/lib/polars/io.rb +18 -25
- data/lib/polars/lazy_frame.rb +367 -53
- data/lib/polars/list_expr.rb +152 -6
- data/lib/polars/list_name_space.rb +102 -0
- data/lib/polars/meta_expr.rb +175 -7
- data/lib/polars/series.rb +273 -34
- data/lib/polars/string_cache.rb +75 -0
- data/lib/polars/string_expr.rb +412 -96
- data/lib/polars/string_name_space.rb +4 -4
- data/lib/polars/testing.rb +507 -0
- data/lib/polars/utils.rb +52 -8
- data/lib/polars/version.rb +1 -1
- data/lib/polars.rb +15 -2
- metadata +35 -5
- data/lib/polars/lazy_functions.rb +0 -1181
data/ext/polars/src/lib.rs
CHANGED
@@ -8,8 +8,8 @@ mod functions;
|
|
8
8
|
mod lazyframe;
|
9
9
|
mod lazygroupby;
|
10
10
|
mod map;
|
11
|
-
mod on_startup;
|
12
11
|
mod object;
|
12
|
+
mod on_startup;
|
13
13
|
mod prelude;
|
14
14
|
pub(crate) mod rb_modules;
|
15
15
|
mod series;
|
@@ -22,6 +22,7 @@ use dataframe::RbDataFrame;
|
|
22
22
|
use error::{RbPolarsErr, RbTypeError, RbValueError};
|
23
23
|
use expr::rb_exprs_to_exprs;
|
24
24
|
use expr::RbExpr;
|
25
|
+
use functions::string_cache::RbStringCacheHolder;
|
25
26
|
use functions::whenthen::{RbThen, RbWhen};
|
26
27
|
use lazyframe::RbLazyFrame;
|
27
28
|
use lazygroupby::RbLazyGroupBy;
|
@@ -48,122 +49,6 @@ type RbResult<T> = Result<T, Error>;
|
|
48
49
|
#[magnus::init]
|
49
50
|
fn init(ruby: &Ruby) -> RbResult<()> {
|
50
51
|
let module = define_module("Polars")?;
|
51
|
-
module.define_singleton_method(
|
52
|
-
"_dtype_cols",
|
53
|
-
function!(crate::functions::lazy::dtype_cols2, 1),
|
54
|
-
)?;
|
55
|
-
module.define_singleton_method(
|
56
|
-
"_concat_lf_diagonal",
|
57
|
-
function!(crate::functions::lazy::concat_lf_diagonal, 4),
|
58
|
-
)?;
|
59
|
-
module.define_singleton_method(
|
60
|
-
"_rb_duration",
|
61
|
-
function!(crate::functions::lazy::duration, 9),
|
62
|
-
)?;
|
63
|
-
module.define_singleton_method(
|
64
|
-
"_concat_df",
|
65
|
-
function!(crate::functions::eager::concat_df, 1),
|
66
|
-
)?;
|
67
|
-
module.define_singleton_method(
|
68
|
-
"_concat_lf",
|
69
|
-
function!(crate::functions::lazy::concat_lf, 4),
|
70
|
-
)?;
|
71
|
-
module.define_singleton_method(
|
72
|
-
"_concat_df_diagonal",
|
73
|
-
function!(crate::functions::eager::concat_df_diagonal, 1),
|
74
|
-
)?;
|
75
|
-
module.define_singleton_method(
|
76
|
-
"_concat_df_horizontal",
|
77
|
-
function!(crate::functions::eager::concat_df_horizontal, 1),
|
78
|
-
)?;
|
79
|
-
module.define_singleton_method(
|
80
|
-
"_concat_series",
|
81
|
-
function!(crate::functions::eager::concat_series, 1),
|
82
|
-
)?;
|
83
|
-
module.define_singleton_method(
|
84
|
-
"_ipc_schema",
|
85
|
-
function!(crate::functions::io::read_ipc_schema, 1),
|
86
|
-
)?;
|
87
|
-
module.define_singleton_method(
|
88
|
-
"_parquet_schema",
|
89
|
-
function!(crate::functions::io::read_parquet_schema, 1),
|
90
|
-
)?;
|
91
|
-
module.define_singleton_method(
|
92
|
-
"_collect_all",
|
93
|
-
function!(crate::functions::lazy::collect_all, 1),
|
94
|
-
)?;
|
95
|
-
module.define_singleton_method(
|
96
|
-
"_rb_date_range",
|
97
|
-
function!(crate::functions::range::date_range, 6),
|
98
|
-
)?;
|
99
|
-
module.define_singleton_method(
|
100
|
-
"_coalesce_exprs",
|
101
|
-
function!(crate::functions::lazy::coalesce, 1),
|
102
|
-
)?;
|
103
|
-
module.define_singleton_method(
|
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),
|
126
|
-
)?;
|
127
|
-
module.define_singleton_method(
|
128
|
-
"_as_struct",
|
129
|
-
function!(crate::functions::lazy::as_struct, 1),
|
130
|
-
)?;
|
131
|
-
module.define_singleton_method(
|
132
|
-
"_arg_where",
|
133
|
-
function!(crate::functions::lazy::arg_where, 1),
|
134
|
-
)?;
|
135
|
-
module.define_singleton_method(
|
136
|
-
"_get_idx_type",
|
137
|
-
function!(crate::functions::meta::get_idx_type, 0),
|
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
|
-
)?;
|
167
52
|
|
168
53
|
let class = module.define_class("RbBatchedCsv", ruby.class_object())?;
|
169
54
|
class.define_singleton_method("new", function!(RbBatchedCsv::new, -1))?;
|
@@ -176,7 +61,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
176
61
|
class.define_singleton_method("read_ipc", function!(RbDataFrame::read_ipc, 6))?;
|
177
62
|
class.define_singleton_method("read_avro", function!(RbDataFrame::read_avro, 4))?;
|
178
63
|
class.define_singleton_method("read_rows", function!(RbDataFrame::read_rows, 3))?;
|
179
|
-
class.define_singleton_method("read_hashes", function!(RbDataFrame::read_hashes,
|
64
|
+
class.define_singleton_method("read_hashes", function!(RbDataFrame::read_hashes, 4))?;
|
180
65
|
class.define_singleton_method("read_hash", function!(RbDataFrame::read_hash, 1))?;
|
181
66
|
class.define_singleton_method("read_json", function!(RbDataFrame::read_json, 1))?;
|
182
67
|
class.define_singleton_method("read_ndjson", function!(RbDataFrame::read_ndjson, 1))?;
|
@@ -228,7 +113,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
228
113
|
"get_column_index",
|
229
114
|
method!(RbDataFrame::get_column_index, 1),
|
230
115
|
)?;
|
231
|
-
class.define_method("
|
116
|
+
class.define_method("get_column", method!(RbDataFrame::get_column, 1))?;
|
232
117
|
class.define_method("select", method!(RbDataFrame::select, 1))?;
|
233
118
|
class.define_method("take", method!(RbDataFrame::take, 1))?;
|
234
119
|
class.define_method(
|
@@ -244,7 +129,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
244
129
|
class.define_method("is_unique", method!(RbDataFrame::is_unique, 0))?;
|
245
130
|
class.define_method("is_duplicated", method!(RbDataFrame::is_duplicated, 0))?;
|
246
131
|
class.define_method("equals", method!(RbDataFrame::equals, 2))?;
|
247
|
-
class.define_method("
|
132
|
+
class.define_method("with_row_index", method!(RbDataFrame::with_row_index, 2))?;
|
248
133
|
class.define_method("_clone", method!(RbDataFrame::clone, 0))?;
|
249
134
|
class.define_method("melt", method!(RbDataFrame::melt, 4))?;
|
250
135
|
class.define_method("pivot_expr", method!(RbDataFrame::pivot_expr, 7))?;
|
@@ -264,6 +149,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
264
149
|
class.define_method("upsample", method!(RbDataFrame::upsample, 5))?;
|
265
150
|
class.define_method("to_struct", method!(RbDataFrame::to_struct, 1))?;
|
266
151
|
class.define_method("unnest", method!(RbDataFrame::unnest, 1))?;
|
152
|
+
class.define_method("clear", method!(RbDataFrame::clear, 0))?;
|
267
153
|
|
268
154
|
let class = module.define_class("RbExpr", ruby.class_object())?;
|
269
155
|
class.define_method("+", method!(RbExpr::add, 1))?;
|
@@ -272,15 +158,18 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
272
158
|
class.define_method("/", method!(RbExpr::truediv, 1))?;
|
273
159
|
class.define_method("%", method!(RbExpr::_mod, 1))?;
|
274
160
|
class.define_method("floordiv", method!(RbExpr::floordiv, 1))?;
|
161
|
+
class.define_method("neg", method!(RbExpr::neg, 0))?;
|
275
162
|
class.define_method("to_str", method!(RbExpr::to_str, 0))?;
|
276
163
|
class.define_method("eq", method!(RbExpr::eq, 1))?;
|
164
|
+
class.define_method("eq_missing", method!(RbExpr::eq_missing, 1))?;
|
277
165
|
class.define_method("neq", method!(RbExpr::neq, 1))?;
|
166
|
+
class.define_method("neq_missing", method!(RbExpr::neq_missing, 1))?;
|
278
167
|
class.define_method("gt", method!(RbExpr::gt, 1))?;
|
279
168
|
class.define_method("gt_eq", method!(RbExpr::gt_eq, 1))?;
|
280
169
|
class.define_method("lt_eq", method!(RbExpr::lt_eq, 1))?;
|
281
170
|
class.define_method("lt", method!(RbExpr::lt, 1))?;
|
282
171
|
class.define_method("_alias", method!(RbExpr::alias, 1))?;
|
283
|
-
class.define_method("
|
172
|
+
class.define_method("not_", method!(RbExpr::not_, 0))?;
|
284
173
|
class.define_method("is_null", method!(RbExpr::is_null, 0))?;
|
285
174
|
class.define_method("is_not_null", method!(RbExpr::is_not_null, 0))?;
|
286
175
|
class.define_method("is_infinite", method!(RbExpr::is_infinite, 0))?;
|
@@ -405,6 +294,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
405
294
|
class.define_method("str_len_chars", method!(RbExpr::str_len_chars, 0))?;
|
406
295
|
class.define_method("str_replace_n", method!(RbExpr::str_replace_n, 4))?;
|
407
296
|
class.define_method("str_replace_all", method!(RbExpr::str_replace_all, 3))?;
|
297
|
+
class.define_method("str_reverse", method!(RbExpr::str_reverse, 0))?;
|
408
298
|
class.define_method("str_zfill", method!(RbExpr::str_zfill, 1))?;
|
409
299
|
class.define_method("str_pad_start", method!(RbExpr::str_pad_start, 2))?;
|
410
300
|
class.define_method("str_pad_end", method!(RbExpr::str_pad_end, 2))?;
|
@@ -414,6 +304,18 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
414
304
|
class.define_method("array_max", method!(RbExpr::array_max, 0))?;
|
415
305
|
class.define_method("array_min", method!(RbExpr::array_min, 0))?;
|
416
306
|
class.define_method("array_sum", method!(RbExpr::array_sum, 0))?;
|
307
|
+
class.define_method("arr_unique", method!(RbExpr::arr_unique, 1))?;
|
308
|
+
class.define_method("arr_to_list", method!(RbExpr::arr_to_list, 0))?;
|
309
|
+
class.define_method("arr_all", method!(RbExpr::arr_all, 0))?;
|
310
|
+
class.define_method("arr_any", method!(RbExpr::arr_any, 0))?;
|
311
|
+
class.define_method("arr_sort", method!(RbExpr::arr_sort, 2))?;
|
312
|
+
class.define_method("arr_reverse", method!(RbExpr::arr_reverse, 0))?;
|
313
|
+
class.define_method("arr_arg_min", method!(RbExpr::arr_arg_min, 0))?;
|
314
|
+
class.define_method("arr_arg_max", method!(RbExpr::arr_arg_max, 0))?;
|
315
|
+
class.define_method("arr_get", method!(RbExpr::arr_get, 1))?;
|
316
|
+
class.define_method("arr_join", method!(RbExpr::arr_join, 2))?;
|
317
|
+
class.define_method("arr_contains", method!(RbExpr::arr_contains, 1))?;
|
318
|
+
class.define_method("arr_count_matches", method!(RbExpr::arr_count_matches, 1))?;
|
417
319
|
class.define_method("binary_contains", method!(RbExpr::bin_contains, 1))?;
|
418
320
|
class.define_method("binary_ends_with", method!(RbExpr::bin_ends_with, 1))?;
|
419
321
|
class.define_method("binary_starts_with", method!(RbExpr::bin_starts_with, 1))?;
|
@@ -422,7 +324,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
422
324
|
class.define_method("str_base64_encode", method!(RbExpr::str_base64_encode, 0))?;
|
423
325
|
class.define_method("str_base64_decode", method!(RbExpr::str_base64_decode, 1))?;
|
424
326
|
class.define_method("str_to_integer", method!(RbExpr::str_to_integer, 2))?;
|
425
|
-
class.define_method("
|
327
|
+
class.define_method("str_json_decode", method!(RbExpr::str_json_decode, 2))?;
|
426
328
|
class.define_method("binary_hex_encode", method!(RbExpr::bin_hex_encode, 0))?;
|
427
329
|
class.define_method("binary_hex_decode", method!(RbExpr::bin_hex_decode, 1))?;
|
428
330
|
class.define_method(
|
@@ -439,6 +341,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
439
341
|
)?;
|
440
342
|
class.define_method("str_extract", method!(RbExpr::str_extract, 2))?;
|
441
343
|
class.define_method("str_extract_all", method!(RbExpr::str_extract_all, 1))?;
|
344
|
+
class.define_method("str_extract_groups", method!(RbExpr::str_extract_groups, 1))?;
|
442
345
|
class.define_method("str_count_matches", method!(RbExpr::str_count_matches, 2))?;
|
443
346
|
class.define_method("strftime", method!(RbExpr::dt_to_string, 1))?;
|
444
347
|
class.define_method("str_split", method!(RbExpr::str_split, 1))?;
|
@@ -452,6 +355,9 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
452
355
|
method!(RbExpr::str_split_exact_inclusive, 2),
|
453
356
|
)?;
|
454
357
|
class.define_method("str_splitn", method!(RbExpr::str_splitn, 2))?;
|
358
|
+
class.define_method("str_to_decimal", method!(RbExpr::str_to_decimal, 1))?;
|
359
|
+
class.define_method("str_contains_any", method!(RbExpr::str_contains_any, 2))?;
|
360
|
+
class.define_method("str_replace_many", method!(RbExpr::str_replace_many, 3))?;
|
455
361
|
class.define_method("list_len", method!(RbExpr::list_len, 0))?;
|
456
362
|
class.define_method("list_contains", method!(RbExpr::list_contains, 1))?;
|
457
363
|
class.define_method("list_count_matches", method!(RbExpr::list_count_matches, 1))?;
|
@@ -473,21 +379,21 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
473
379
|
class.define_method("millisecond", method!(RbExpr::dt_millisecond, 0))?;
|
474
380
|
class.define_method("microsecond", method!(RbExpr::dt_microsecond, 0))?;
|
475
381
|
class.define_method("nanosecond", method!(RbExpr::dt_nanosecond, 0))?;
|
476
|
-
class.define_method("
|
477
|
-
class.define_method("
|
478
|
-
class.define_method("
|
479
|
-
class.define_method("
|
382
|
+
class.define_method("dt_total_days", method!(RbExpr::dt_total_days, 0))?;
|
383
|
+
class.define_method("dt_total_hours", method!(RbExpr::dt_total_hours, 0))?;
|
384
|
+
class.define_method("dt_total_minutes", method!(RbExpr::dt_total_minutes, 0))?;
|
385
|
+
class.define_method("dt_total_seconds", method!(RbExpr::dt_total_seconds, 0))?;
|
480
386
|
class.define_method(
|
481
|
-
"
|
482
|
-
method!(RbExpr::
|
387
|
+
"dt_total_nanoseconds",
|
388
|
+
method!(RbExpr::dt_total_nanoseconds, 0),
|
483
389
|
)?;
|
484
390
|
class.define_method(
|
485
|
-
"
|
486
|
-
method!(RbExpr::
|
391
|
+
"dt_total_microseconds",
|
392
|
+
method!(RbExpr::dt_total_microseconds, 0),
|
487
393
|
)?;
|
488
394
|
class.define_method(
|
489
|
-
"
|
490
|
-
method!(RbExpr::
|
395
|
+
"dt_total_milliseconds",
|
396
|
+
method!(RbExpr::dt_total_milliseconds, 0),
|
491
397
|
)?;
|
492
398
|
class.define_method("timestamp", method!(RbExpr::dt_timestamp, 1))?;
|
493
399
|
class.define_method("dt_offset_by", method!(RbExpr::dt_offset_by, 1))?;
|
@@ -505,6 +411,8 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
505
411
|
class.define_method("dt_truncate", method!(RbExpr::dt_truncate, 2))?;
|
506
412
|
class.define_method("dt_month_start", method!(RbExpr::dt_month_start, 0))?;
|
507
413
|
class.define_method("dt_month_end", method!(RbExpr::dt_month_end, 0))?;
|
414
|
+
class.define_method("dt_base_utc_offset", method!(RbExpr::dt_base_utc_offset, 0))?;
|
415
|
+
class.define_method("dt_dst_offset", method!(RbExpr::dt_dst_offset, 0))?;
|
508
416
|
class.define_method("dt_round", method!(RbExpr::dt_round, 2))?;
|
509
417
|
class.define_method("dt_combine", method!(RbExpr::dt_combine, 2))?;
|
510
418
|
class.define_method("map", method!(RbExpr::map, 3))?;
|
@@ -527,15 +435,25 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
527
435
|
class.define_method("list_max", method!(RbExpr::list_max, 0))?;
|
528
436
|
class.define_method("list_min", method!(RbExpr::list_min, 0))?;
|
529
437
|
class.define_method("list_sum", method!(RbExpr::list_sum, 0))?;
|
530
|
-
class.define_method("
|
438
|
+
class.define_method("list_drop_nulls", method!(RbExpr::list_drop_nulls, 0))?;
|
439
|
+
class.define_method("list_sample_n", method!(RbExpr::list_sample_n, 4))?;
|
440
|
+
class.define_method(
|
441
|
+
"list_sample_fraction",
|
442
|
+
method!(RbExpr::list_sample_fraction, 4),
|
443
|
+
)?;
|
444
|
+
class.define_method("list_gather", method!(RbExpr::list_gather, 2))?;
|
445
|
+
class.define_method("list_to_array", method!(RbExpr::list_to_array, 1))?;
|
531
446
|
class.define_method("list_mean", method!(RbExpr::list_mean, 0))?;
|
447
|
+
class.define_method("list_tail", method!(RbExpr::list_tail, 1))?;
|
532
448
|
class.define_method("list_sort", method!(RbExpr::list_sort, 1))?;
|
533
449
|
class.define_method("list_reverse", method!(RbExpr::list_reverse, 0))?;
|
534
450
|
class.define_method("list_unique", method!(RbExpr::list_unique, 1))?;
|
535
451
|
class.define_method("list_get", method!(RbExpr::list_get, 1))?;
|
536
|
-
class.define_method("list_join", method!(RbExpr::list_join,
|
452
|
+
class.define_method("list_join", method!(RbExpr::list_join, 2))?;
|
537
453
|
class.define_method("list_arg_min", method!(RbExpr::list_arg_min, 0))?;
|
538
454
|
class.define_method("list_arg_max", method!(RbExpr::list_arg_max, 0))?;
|
455
|
+
class.define_method("list_all", method!(RbExpr::list_all, 0))?;
|
456
|
+
class.define_method("list_any", method!(RbExpr::list_any, 0))?;
|
539
457
|
class.define_method("list_diff", method!(RbExpr::list_diff, 2))?;
|
540
458
|
class.define_method("list_shift", method!(RbExpr::list_shift, 1))?;
|
541
459
|
class.define_method("list_slice", method!(RbExpr::list_slice, 2))?;
|
@@ -574,11 +492,13 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
574
492
|
"struct_rename_fields",
|
575
493
|
method!(RbExpr::struct_rename_fields, 1),
|
576
494
|
)?;
|
495
|
+
class.define_method("struct_json_encode", method!(RbExpr::struct_json_encode, 0))?;
|
577
496
|
class.define_method("log", method!(RbExpr::log, 1))?;
|
578
497
|
class.define_method("exp", method!(RbExpr::exp, 0))?;
|
579
498
|
class.define_method("entropy", method!(RbExpr::entropy, 2))?;
|
580
499
|
class.define_method("_hash", method!(RbExpr::hash, 4))?;
|
581
500
|
class.define_method("set_sorted_flag", method!(RbExpr::set_sorted_flag, 1))?;
|
501
|
+
class.define_method("replace", method!(RbExpr::replace, 4))?;
|
582
502
|
|
583
503
|
// meta
|
584
504
|
class.define_method("meta_pop", method!(RbExpr::meta_pop, 0))?;
|
@@ -590,10 +510,16 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
590
510
|
"meta_has_multiple_outputs",
|
591
511
|
method!(RbExpr::meta_has_multiple_outputs, 0),
|
592
512
|
)?;
|
513
|
+
class.define_method("meta_is_column", method!(RbExpr::meta_is_column, 0))?;
|
593
514
|
class.define_method(
|
594
515
|
"meta_is_regex_projection",
|
595
516
|
method!(RbExpr::meta_is_regex_projection, 0),
|
596
517
|
)?;
|
518
|
+
class.define_method("_meta_selector_add", method!(RbExpr::_meta_selector_add, 1))?;
|
519
|
+
class.define_method("_meta_selector_sub", method!(RbExpr::_meta_selector_sub, 1))?;
|
520
|
+
class.define_method("_meta_selector_and", method!(RbExpr::_meta_selector_and, 1))?;
|
521
|
+
class.define_method("_meta_as_selector", method!(RbExpr::_meta_as_selector, 0))?;
|
522
|
+
class.define_method("meta_tree_format", method!(RbExpr::meta_tree_format, 0))?;
|
597
523
|
|
598
524
|
// name
|
599
525
|
class.define_method("name_keep", method!(RbExpr::name_keep, 0))?;
|
@@ -604,44 +530,154 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
604
530
|
class.define_method("name_to_uppercase", method!(RbExpr::name_to_uppercase, 0))?;
|
605
531
|
|
606
532
|
// maybe add to different class
|
607
|
-
class.
|
608
|
-
class.define_singleton_method("
|
609
|
-
class.define_singleton_method("
|
610
|
-
class.define_singleton_method("
|
611
|
-
class.define_singleton_method("
|
612
|
-
class.define_singleton_method("
|
613
|
-
class.define_singleton_method("
|
614
|
-
class.define_singleton_method("
|
533
|
+
let class = module.define_module("Plr")?;
|
534
|
+
class.define_singleton_method("dtype_cols", function!(functions::lazy::dtype_cols2, 1))?;
|
535
|
+
class.define_singleton_method("col", function!(functions::lazy::col, 1))?;
|
536
|
+
class.define_singleton_method("len", function!(functions::lazy::len, 0))?;
|
537
|
+
class.define_singleton_method("first", function!(functions::lazy::first, 0))?;
|
538
|
+
class.define_singleton_method("last", function!(functions::lazy::last, 0))?;
|
539
|
+
class.define_singleton_method("cols", function!(functions::lazy::cols, 1))?;
|
540
|
+
class.define_singleton_method("fold", function!(functions::lazy::fold, 3))?;
|
541
|
+
class.define_singleton_method("cum_fold", function!(functions::lazy::cum_fold, 4))?;
|
542
|
+
class.define_singleton_method("lit", function!(functions::lazy::lit, 2))?;
|
543
|
+
class.define_singleton_method("int_range", function!(functions::range::int_range, 4))?;
|
544
|
+
class.define_singleton_method("int_ranges", function!(functions::range::int_ranges, 4))?;
|
545
|
+
class.define_singleton_method("repeat", function!(functions::lazy::repeat, 3))?;
|
546
|
+
class.define_singleton_method("pearson_corr", function!(functions::lazy::pearson_corr, 3))?;
|
615
547
|
class.define_singleton_method(
|
616
|
-
"
|
617
|
-
function!(
|
548
|
+
"spearman_rank_corr",
|
549
|
+
function!(functions::lazy::spearman_rank_corr, 4),
|
550
|
+
)?;
|
551
|
+
class.define_singleton_method("sql_expr", function!(functions::lazy::sql_expr, 1))?;
|
552
|
+
class.define_singleton_method("cov", function!(functions::lazy::cov, 3))?;
|
553
|
+
class.define_singleton_method("arctan2", function!(functions::lazy::arctan2, 2))?;
|
554
|
+
class.define_singleton_method("arctan2d", function!(functions::lazy::arctan2d, 2))?;
|
555
|
+
class.define_singleton_method("rolling_corr", function!(functions::lazy::rolling_corr, 5))?;
|
556
|
+
class.define_singleton_method("rolling_cov", function!(functions::lazy::rolling_cov, 5))?;
|
557
|
+
class.define_singleton_method("arg_sort_by", function!(functions::lazy::arg_sort_by, 2))?;
|
558
|
+
class.define_singleton_method("when", function!(functions::whenthen::when, 1))?;
|
559
|
+
class.define_singleton_method("concat_str", function!(functions::lazy::concat_str, 3))?;
|
560
|
+
class.define_singleton_method("concat_list", function!(functions::lazy::concat_list, 1))?;
|
561
|
+
class.define_singleton_method(
|
562
|
+
"all_horizontal",
|
563
|
+
function!(functions::aggregation::all_horizontal, 1),
|
618
564
|
)?;
|
619
565
|
class.define_singleton_method(
|
620
|
-
"
|
621
|
-
function!(
|
566
|
+
"any_horizontal",
|
567
|
+
function!(functions::aggregation::any_horizontal, 1),
|
622
568
|
)?;
|
623
|
-
class.define_singleton_method("repeat", function!(crate::functions::lazy::repeat, 3))?;
|
624
569
|
class.define_singleton_method(
|
625
|
-
"
|
626
|
-
function!(
|
570
|
+
"max_horizontal",
|
571
|
+
function!(functions::aggregation::max_horizontal, 1),
|
627
572
|
)?;
|
628
573
|
class.define_singleton_method(
|
629
|
-
"
|
630
|
-
function!(
|
574
|
+
"min_horizontal",
|
575
|
+
function!(functions::aggregation::min_horizontal, 1),
|
576
|
+
)?;
|
577
|
+
class.define_singleton_method(
|
578
|
+
"sum_horizontal",
|
579
|
+
function!(functions::aggregation::sum_horizontal, 1),
|
631
580
|
)?;
|
632
|
-
class.define_singleton_method("cov", function!(crate::functions::lazy::cov, 3))?;
|
633
581
|
class.define_singleton_method(
|
634
|
-
"
|
635
|
-
function!(
|
582
|
+
"mean_horizontal",
|
583
|
+
function!(functions::aggregation::mean_horizontal, 1),
|
636
584
|
)?;
|
637
|
-
class.define_singleton_method("
|
585
|
+
class.define_singleton_method("as_struct", function!(functions::lazy::as_struct, 1))?;
|
586
|
+
class.define_singleton_method("coalesce", function!(functions::lazy::coalesce, 1))?;
|
587
|
+
class.define_singleton_method("arg_where", function!(functions::lazy::arg_where, 1))?;
|
638
588
|
class.define_singleton_method(
|
639
|
-
"
|
640
|
-
function!(
|
589
|
+
"concat_lf_diagonal",
|
590
|
+
function!(functions::lazy::concat_lf_diagonal, 4),
|
641
591
|
)?;
|
592
|
+
class.define_singleton_method("concat_df", function!(functions::eager::concat_df, 1))?;
|
593
|
+
class.define_singleton_method("concat_lf", function!(functions::lazy::concat_lf, 4))?;
|
642
594
|
class.define_singleton_method(
|
643
|
-
"
|
644
|
-
function!(
|
595
|
+
"concat_df_diagonal",
|
596
|
+
function!(functions::eager::concat_df_diagonal, 1),
|
597
|
+
)?;
|
598
|
+
class.define_singleton_method(
|
599
|
+
"concat_df_horizontal",
|
600
|
+
function!(functions::eager::concat_df_horizontal, 1),
|
601
|
+
)?;
|
602
|
+
class.define_singleton_method(
|
603
|
+
"concat_series",
|
604
|
+
function!(functions::eager::concat_series, 1),
|
605
|
+
)?;
|
606
|
+
class.define_singleton_method("duration", function!(functions::lazy::duration, 9))?;
|
607
|
+
class.define_singleton_method("ipc_schema", function!(functions::io::read_ipc_schema, 1))?;
|
608
|
+
class.define_singleton_method(
|
609
|
+
"parquet_schema",
|
610
|
+
function!(functions::io::read_parquet_schema, 1),
|
611
|
+
)?;
|
612
|
+
class.define_singleton_method("collect_all", function!(functions::lazy::collect_all, 1))?;
|
613
|
+
class.define_singleton_method("date_range", function!(functions::range::date_range, 6))?;
|
614
|
+
class.define_singleton_method(
|
615
|
+
"dtype_str_repr",
|
616
|
+
function!(functions::misc::dtype_str_repr, 1),
|
617
|
+
)?;
|
618
|
+
class.define_singleton_method(
|
619
|
+
"get_index_type",
|
620
|
+
function!(functions::meta::get_index_type, 0),
|
621
|
+
)?;
|
622
|
+
class.define_singleton_method(
|
623
|
+
"threadpool_size",
|
624
|
+
function!(functions::meta::threadpool_size, 0),
|
625
|
+
)?;
|
626
|
+
class.define_singleton_method(
|
627
|
+
"enable_string_cache",
|
628
|
+
function!(functions::string_cache::enable_string_cache, 0),
|
629
|
+
)?;
|
630
|
+
class.define_singleton_method(
|
631
|
+
"disable_string_cache",
|
632
|
+
function!(functions::string_cache::disable_string_cache, 0),
|
633
|
+
)?;
|
634
|
+
class.define_singleton_method(
|
635
|
+
"using_string_cache",
|
636
|
+
function!(functions::string_cache::using_string_cache, 0),
|
637
|
+
)?;
|
638
|
+
class.define_singleton_method(
|
639
|
+
"set_float_fmt",
|
640
|
+
function!(functions::meta::set_float_fmt, 1),
|
641
|
+
)?;
|
642
|
+
class.define_singleton_method(
|
643
|
+
"get_float_fmt",
|
644
|
+
function!(functions::meta::get_float_fmt, 0),
|
645
|
+
)?;
|
646
|
+
class.define_singleton_method(
|
647
|
+
"set_float_precision",
|
648
|
+
function!(functions::meta::set_float_precision, 1),
|
649
|
+
)?;
|
650
|
+
class.define_singleton_method(
|
651
|
+
"get_float_precision",
|
652
|
+
function!(functions::meta::get_float_precision, 0),
|
653
|
+
)?;
|
654
|
+
class.define_singleton_method(
|
655
|
+
"set_thousands_separator",
|
656
|
+
function!(functions::meta::set_thousands_separator, 1),
|
657
|
+
)?;
|
658
|
+
class.define_singleton_method(
|
659
|
+
"get_thousands_separator",
|
660
|
+
function!(functions::meta::get_thousands_separator, 0),
|
661
|
+
)?;
|
662
|
+
class.define_singleton_method(
|
663
|
+
"set_decimal_separator",
|
664
|
+
function!(functions::meta::set_decimal_separator, 1),
|
665
|
+
)?;
|
666
|
+
class.define_singleton_method(
|
667
|
+
"get_decimal_separator",
|
668
|
+
function!(functions::meta::get_decimal_separator, 0),
|
669
|
+
)?;
|
670
|
+
class.define_singleton_method(
|
671
|
+
"set_trim_decimal_zeros",
|
672
|
+
function!(functions::meta::set_trim_decimal_zeros, 1),
|
673
|
+
)?;
|
674
|
+
class.define_singleton_method(
|
675
|
+
"get_trim_decimal_zeros",
|
676
|
+
function!(functions::meta::get_trim_decimal_zeros, 0),
|
677
|
+
)?;
|
678
|
+
class.define_singleton_method(
|
679
|
+
"set_random_seed",
|
680
|
+
function!(functions::random::set_random_seed, 1),
|
645
681
|
)?;
|
646
682
|
|
647
683
|
let class = module.define_class("RbLazyFrame", ruby.class_object())?;
|
@@ -664,29 +700,35 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
664
700
|
)?;
|
665
701
|
class.define_method(
|
666
702
|
"optimization_toggle",
|
667
|
-
method!(RbLazyFrame::optimization_toggle,
|
703
|
+
method!(RbLazyFrame::optimization_toggle, 9),
|
668
704
|
)?;
|
669
705
|
class.define_method("sort", method!(RbLazyFrame::sort, 4))?;
|
670
706
|
class.define_method("sort_by_exprs", method!(RbLazyFrame::sort_by_exprs, 4))?;
|
671
707
|
class.define_method("cache", method!(RbLazyFrame::cache, 0))?;
|
672
708
|
class.define_method("collect", method!(RbLazyFrame::collect, 0))?;
|
673
709
|
class.define_method("sink_parquet", method!(RbLazyFrame::sink_parquet, 7))?;
|
710
|
+
class.define_method("sink_ipc", method!(RbLazyFrame::sink_ipc, 3))?;
|
711
|
+
class.define_method("sink_csv", method!(RbLazyFrame::sink_csv, 14))?;
|
712
|
+
class.define_method("sink_json", method!(RbLazyFrame::sink_json, 2))?;
|
674
713
|
class.define_method("fetch", method!(RbLazyFrame::fetch, 1))?;
|
675
714
|
class.define_method("filter", method!(RbLazyFrame::filter, 1))?;
|
676
715
|
class.define_method("select", method!(RbLazyFrame::select, 1))?;
|
716
|
+
class.define_method("select_seq", method!(RbLazyFrame::select_seq, 1))?;
|
677
717
|
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
|
-
)?;
|
718
|
+
class.define_method("rolling", method!(RbLazyFrame::rolling, 6))?;
|
682
719
|
class.define_method(
|
683
720
|
"group_by_dynamic",
|
684
721
|
method!(RbLazyFrame::group_by_dynamic, 10),
|
685
722
|
)?;
|
686
723
|
class.define_method("with_context", method!(RbLazyFrame::with_context, 1))?;
|
687
724
|
class.define_method("join_asof", method!(RbLazyFrame::join_asof, 11))?;
|
688
|
-
class.define_method("join", method!(RbLazyFrame::join,
|
725
|
+
class.define_method("join", method!(RbLazyFrame::join, 8))?;
|
726
|
+
class.define_method("with_column", method!(RbLazyFrame::with_column, 1))?;
|
689
727
|
class.define_method("with_columns", method!(RbLazyFrame::with_columns, 1))?;
|
728
|
+
class.define_method(
|
729
|
+
"with_columns_seq",
|
730
|
+
method!(RbLazyFrame::with_columns_seq, 1),
|
731
|
+
)?;
|
690
732
|
class.define_method("rename", method!(RbLazyFrame::rename, 2))?;
|
691
733
|
class.define_method("reverse", method!(RbLazyFrame::reverse, 0))?;
|
692
734
|
class.define_method("shift", method!(RbLazyFrame::shift, 2))?;
|
@@ -700,19 +742,23 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
700
742
|
class.define_method("median", method!(RbLazyFrame::median, 0))?;
|
701
743
|
class.define_method("quantile", method!(RbLazyFrame::quantile, 2))?;
|
702
744
|
class.define_method("explode", method!(RbLazyFrame::explode, 1))?;
|
745
|
+
class.define_method("null_count", method!(RbLazyFrame::null_count, 0))?;
|
703
746
|
class.define_method("unique", method!(RbLazyFrame::unique, 3))?;
|
704
747
|
class.define_method("drop_nulls", method!(RbLazyFrame::drop_nulls, 1))?;
|
705
748
|
class.define_method("slice", method!(RbLazyFrame::slice, 2))?;
|
706
749
|
class.define_method("tail", method!(RbLazyFrame::tail, 1))?;
|
707
750
|
class.define_method("melt", method!(RbLazyFrame::melt, 5))?;
|
708
|
-
class.define_method("
|
709
|
-
class.define_method("
|
751
|
+
class.define_method("with_row_index", method!(RbLazyFrame::with_row_index, 2))?;
|
752
|
+
class.define_method("drop", method!(RbLazyFrame::drop, 1))?;
|
753
|
+
class.define_method("cast_all", method!(RbLazyFrame::cast_all, 2))?;
|
710
754
|
class.define_method("_clone", method!(RbLazyFrame::clone, 0))?;
|
711
755
|
class.define_method("columns", method!(RbLazyFrame::columns, 0))?;
|
712
756
|
class.define_method("dtypes", method!(RbLazyFrame::dtypes, 0))?;
|
713
757
|
class.define_method("schema", method!(RbLazyFrame::schema, 0))?;
|
714
758
|
class.define_method("unnest", method!(RbLazyFrame::unnest, 1))?;
|
715
759
|
class.define_method("width", method!(RbLazyFrame::width, 0))?;
|
760
|
+
class.define_method("count", method!(RbLazyFrame::count, 0))?;
|
761
|
+
class.define_method("merge_sorted", method!(RbLazyFrame::merge_sorted, 2))?;
|
716
762
|
|
717
763
|
let class = module.define_class("RbLazyGroupBy", ruby.class_object())?;
|
718
764
|
class.define_method("agg", method!(RbLazyGroupBy::agg, 1))?;
|
@@ -756,6 +802,12 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
756
802
|
"can_fast_explode_flag",
|
757
803
|
method!(RbSeries::can_fast_explode_flag, 0),
|
758
804
|
)?;
|
805
|
+
class.define_method(
|
806
|
+
"cat_uses_lexical_ordering",
|
807
|
+
method!(RbSeries::cat_uses_lexical_ordering, 0),
|
808
|
+
)?;
|
809
|
+
class.define_method("cat_is_local", method!(RbSeries::cat_is_local, 0))?;
|
810
|
+
class.define_method("cat_to_local", method!(RbSeries::cat_to_local, 0))?;
|
759
811
|
class.define_method("estimated_size", method!(RbSeries::estimated_size, 0))?;
|
760
812
|
class.define_method("get_fmt", method!(RbSeries::get_fmt, 2))?;
|
761
813
|
class.define_method("rechunk", method!(RbSeries::rechunk, 1))?;
|
@@ -783,8 +835,10 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
783
835
|
class.define_method("mul", method!(RbSeries::mul, 1))?;
|
784
836
|
class.define_method("div", method!(RbSeries::div, 1))?;
|
785
837
|
class.define_method("rem", method!(RbSeries::rem, 1))?;
|
786
|
-
class.define_method("sort", method!(RbSeries::sort,
|
838
|
+
class.define_method("sort", method!(RbSeries::sort, 2))?;
|
787
839
|
class.define_method("value_counts", method!(RbSeries::value_counts, 1))?;
|
840
|
+
class.define_method("any", method!(RbSeries::any, 1))?;
|
841
|
+
class.define_method("all", method!(RbSeries::all, 1))?;
|
788
842
|
class.define_method("arg_min", method!(RbSeries::arg_min, 0))?;
|
789
843
|
class.define_method("arg_max", method!(RbSeries::arg_max, 0))?;
|
790
844
|
class.define_method("take_with_series", method!(RbSeries::take_with_series, 1))?;
|
@@ -992,5 +1046,9 @@ fn init(ruby: &Ruby) -> RbResult<()> {
|
|
992
1046
|
class.define_method("register", method!(RbSQLContext::register, 2))?;
|
993
1047
|
class.define_method("unregister", method!(RbSQLContext::unregister, 1))?;
|
994
1048
|
|
1049
|
+
// string cache
|
1050
|
+
let class = module.define_class("RbStringCacheHolder", ruby.class_object())?;
|
1051
|
+
class.define_singleton_method("hold", function!(RbStringCacheHolder::hold, 0))?;
|
1052
|
+
|
995
1053
|
Ok(())
|
996
1054
|
}
|
@@ -4,6 +4,26 @@ use crate::{RbResult, RbSeries, RbValueError};
|
|
4
4
|
use magnus::{IntoValue, Value};
|
5
5
|
|
6
6
|
impl RbSeries {
|
7
|
+
pub fn any(&self, ignore_nulls: bool) -> RbResult<Option<bool>> {
|
8
|
+
let binding = self.series.borrow();
|
9
|
+
let s = binding.bool().map_err(RbPolarsErr::from)?;
|
10
|
+
Ok(if ignore_nulls {
|
11
|
+
Some(s.any())
|
12
|
+
} else {
|
13
|
+
s.any_kleene()
|
14
|
+
})
|
15
|
+
}
|
16
|
+
|
17
|
+
pub fn all(&self, ignore_nulls: bool) -> RbResult<Option<bool>> {
|
18
|
+
let binding = self.series.borrow();
|
19
|
+
let s = binding.bool().map_err(RbPolarsErr::from)?;
|
20
|
+
Ok(if ignore_nulls {
|
21
|
+
Some(s.all())
|
22
|
+
} else {
|
23
|
+
s.all_kleene()
|
24
|
+
})
|
25
|
+
}
|
26
|
+
|
7
27
|
pub fn arg_max(&self) -> Option<usize> {
|
8
28
|
self.series.borrow().arg_max()
|
9
29
|
}
|