polars-df 0.23.0 → 0.24.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +127 -1
- data/Cargo.lock +72 -58
- data/README.md +31 -27
- data/ext/polars/Cargo.toml +15 -6
- data/ext/polars/src/batched_csv.rs +35 -39
- data/ext/polars/src/c_api/allocator.rs +7 -0
- data/ext/polars/src/c_api/mod.rs +1 -0
- data/ext/polars/src/catalog/unity.rs +123 -101
- data/ext/polars/src/conversion/any_value.rs +13 -17
- data/ext/polars/src/conversion/chunked_array.rs +5 -5
- data/ext/polars/src/conversion/datetime.rs +3 -2
- data/ext/polars/src/conversion/mod.rs +50 -45
- data/ext/polars/src/dataframe/export.rs +13 -13
- data/ext/polars/src/dataframe/general.rs +223 -223
- data/ext/polars/src/dataframe/io.rs +27 -141
- data/ext/polars/src/dataframe/mod.rs +13 -5
- data/ext/polars/src/dataframe/serde.rs +1 -1
- data/ext/polars/src/error.rs +44 -7
- data/ext/polars/src/exceptions.rs +45 -12
- data/ext/polars/src/expr/array.rs +12 -0
- data/ext/polars/src/expr/datatype.rs +2 -2
- data/ext/polars/src/expr/datetime.rs +4 -5
- data/ext/polars/src/expr/general.rs +49 -13
- data/ext/polars/src/expr/list.rs +4 -0
- data/ext/polars/src/expr/meta.rs +8 -3
- data/ext/polars/src/expr/mod.rs +22 -6
- data/ext/polars/src/expr/name.rs +19 -8
- data/ext/polars/src/expr/rolling.rs +50 -1
- data/ext/polars/src/expr/string.rs +0 -1
- data/ext/polars/src/expr/struct.rs +7 -2
- data/ext/polars/src/file.rs +136 -103
- data/ext/polars/src/functions/aggregation.rs +9 -8
- data/ext/polars/src/functions/io.rs +81 -10
- data/ext/polars/src/functions/lazy.rs +95 -21
- data/ext/polars/src/functions/mod.rs +2 -0
- data/ext/polars/src/functions/range.rs +19 -3
- data/ext/polars/src/functions/strings.rs +6 -0
- data/ext/polars/src/functions/utils.rs +6 -0
- data/ext/polars/src/interop/arrow/mod.rs +50 -1
- data/ext/polars/src/interop/arrow/{to_ruby.rs → to_rb.rs} +30 -0
- data/ext/polars/src/interop/arrow/to_rust.rs +43 -0
- data/ext/polars/src/interop/numo/to_numo_df.rs +1 -1
- data/ext/polars/src/interop/numo/to_numo_series.rs +1 -1
- data/ext/polars/src/lazyframe/exitable.rs +39 -0
- data/ext/polars/src/lazyframe/general.rs +340 -236
- data/ext/polars/src/lazyframe/mod.rs +46 -10
- data/ext/polars/src/lazyframe/optflags.rs +5 -4
- data/ext/polars/src/lazyframe/serde.rs +11 -3
- data/ext/polars/src/lazyframe/sink.rs +10 -5
- data/ext/polars/src/lazygroupby.rs +6 -7
- data/ext/polars/src/lib.rs +141 -76
- data/ext/polars/src/map/dataframe.rs +12 -12
- data/ext/polars/src/map/lazy.rs +7 -5
- data/ext/polars/src/map/mod.rs +15 -8
- data/ext/polars/src/map/series.rs +3 -3
- data/ext/polars/src/on_startup.rs +16 -8
- data/ext/polars/src/prelude.rs +1 -0
- data/ext/polars/src/rb_modules.rs +19 -49
- data/ext/polars/src/series/aggregation.rs +79 -140
- data/ext/polars/src/series/arithmetic.rs +16 -22
- data/ext/polars/src/series/comparison.rs +101 -222
- data/ext/polars/src/series/construction.rs +17 -18
- data/ext/polars/src/series/export.rs +1 -1
- data/ext/polars/src/series/general.rs +254 -289
- data/ext/polars/src/series/import.rs +17 -0
- data/ext/polars/src/series/map.rs +178 -160
- data/ext/polars/src/series/mod.rs +28 -12
- data/ext/polars/src/series/scatter.rs +12 -9
- data/ext/polars/src/sql.rs +16 -9
- data/ext/polars/src/testing/frame.rs +31 -0
- data/ext/polars/src/testing/mod.rs +5 -0
- data/ext/polars/src/testing/series.rs +31 -0
- data/ext/polars/src/timeout.rs +105 -0
- data/ext/polars/src/utils.rs +159 -1
- data/lib/polars/array_expr.rb +81 -12
- data/lib/polars/array_name_space.rb +74 -7
- data/lib/polars/batched_csv_reader.rb +21 -21
- data/lib/polars/binary_name_space.rb +1 -1
- data/lib/polars/cat_expr.rb +7 -7
- data/lib/polars/config.rb +1 -1
- data/lib/polars/convert.rb +189 -34
- data/lib/polars/data_frame.rb +1066 -831
- data/lib/polars/data_frame_plot.rb +173 -0
- data/lib/polars/data_type_group.rb +1 -0
- data/lib/polars/data_types.rb +31 -12
- data/lib/polars/date_time_expr.rb +51 -69
- data/lib/polars/date_time_name_space.rb +80 -112
- data/lib/polars/dynamic_group_by.rb +7 -7
- data/lib/polars/exceptions.rb +50 -10
- data/lib/polars/expr.rb +470 -517
- data/lib/polars/functions/aggregation/horizontal.rb +0 -1
- data/lib/polars/functions/aggregation/vertical.rb +2 -3
- data/lib/polars/functions/as_datatype.rb +290 -8
- data/lib/polars/functions/eager.rb +204 -10
- data/lib/polars/functions/escape_regex.rb +21 -0
- data/lib/polars/functions/lazy.rb +409 -169
- data/lib/polars/functions/lit.rb +17 -1
- data/lib/polars/functions/range/int_range.rb +74 -2
- data/lib/polars/functions/range/linear_space.rb +77 -0
- data/lib/polars/functions/range/time_range.rb +1 -1
- data/lib/polars/functions/repeat.rb +3 -12
- data/lib/polars/functions/whenthen.rb +2 -2
- data/lib/polars/group_by.rb +72 -20
- data/lib/polars/iceberg_dataset.rb +1 -6
- data/lib/polars/in_process_query.rb +37 -0
- data/lib/polars/io/cloud.rb +18 -0
- data/lib/polars/io/csv.rb +265 -126
- data/lib/polars/io/database.rb +0 -1
- data/lib/polars/io/delta.rb +15 -7
- data/lib/polars/io/ipc.rb +24 -17
- data/lib/polars/io/ndjson.rb +161 -24
- data/lib/polars/io/parquet.rb +101 -38
- data/lib/polars/lazy_frame.rb +849 -558
- data/lib/polars/lazy_group_by.rb +327 -2
- data/lib/polars/list_expr.rb +94 -16
- data/lib/polars/list_name_space.rb +88 -24
- data/lib/polars/meta_expr.rb +42 -1
- data/lib/polars/name_expr.rb +41 -4
- data/lib/polars/query_opt_flags.rb +198 -2
- data/lib/polars/rolling_group_by.rb +3 -3
- data/lib/polars/schema.rb +21 -3
- data/lib/polars/selector.rb +37 -2
- data/lib/polars/selectors.rb +45 -9
- data/lib/polars/series.rb +1156 -728
- data/lib/polars/series_plot.rb +72 -0
- data/lib/polars/slice.rb +1 -1
- data/lib/polars/sql_context.rb +11 -4
- data/lib/polars/string_expr.rb +59 -68
- data/lib/polars/string_name_space.rb +51 -87
- data/lib/polars/struct_expr.rb +36 -18
- data/lib/polars/testing.rb +24 -273
- data/lib/polars/utils/constants.rb +2 -0
- data/lib/polars/utils/construction/data_frame.rb +410 -0
- data/lib/polars/utils/construction/series.rb +364 -0
- data/lib/polars/utils/construction/utils.rb +9 -0
- data/lib/polars/utils/deprecation.rb +11 -0
- data/lib/polars/utils/serde.rb +8 -3
- data/lib/polars/utils/unstable.rb +19 -0
- data/lib/polars/utils/various.rb +59 -0
- data/lib/polars/utils.rb +46 -47
- data/lib/polars/version.rb +1 -1
- data/lib/polars.rb +47 -1
- metadata +25 -6
- data/ext/polars/src/allocator.rs +0 -13
- data/lib/polars/plot.rb +0 -109
|
@@ -1,251 +1,130 @@
|
|
|
1
|
-
use
|
|
1
|
+
use magnus::Ruby;
|
|
2
|
+
|
|
2
3
|
use crate::prelude::*;
|
|
4
|
+
use crate::utils::EnterPolarsExt;
|
|
3
5
|
use crate::{RbResult, RbSeries};
|
|
4
6
|
|
|
5
7
|
impl RbSeries {
|
|
6
|
-
pub fn eq(&
|
|
7
|
-
|
|
8
|
-
.series
|
|
9
|
-
.borrow()
|
|
10
|
-
.equal(&*rhs.series.borrow())
|
|
11
|
-
.map_err(RbPolarsErr::from)?;
|
|
12
|
-
Ok(Self::new(s.into_series()))
|
|
8
|
+
pub fn eq(rb: &Ruby, self_: &Self, rhs: &RbSeries) -> RbResult<Self> {
|
|
9
|
+
rb.enter_polars_series(|| self_.series.read().equal(&*rhs.series.read()))
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
pub fn neq(&
|
|
16
|
-
|
|
17
|
-
.series
|
|
18
|
-
.borrow()
|
|
19
|
-
.not_equal(&*rhs.series.borrow())
|
|
20
|
-
.map_err(RbPolarsErr::from)?;
|
|
21
|
-
Ok(Self::new(s.into_series()))
|
|
12
|
+
pub fn neq(rb: &Ruby, self_: &Self, rhs: &RbSeries) -> RbResult<Self> {
|
|
13
|
+
rb.enter_polars_series(|| self_.series.read().not_equal(&*rhs.series.read()))
|
|
22
14
|
}
|
|
23
15
|
|
|
24
|
-
pub fn gt(&
|
|
25
|
-
|
|
26
|
-
.series
|
|
27
|
-
.borrow()
|
|
28
|
-
.gt(&*rhs.series.borrow())
|
|
29
|
-
.map_err(RbPolarsErr::from)?;
|
|
30
|
-
Ok(Self::new(s.into_series()))
|
|
16
|
+
pub fn gt(rb: &Ruby, self_: &Self, rhs: &RbSeries) -> RbResult<Self> {
|
|
17
|
+
rb.enter_polars_series(|| self_.series.read().gt(&*rhs.series.read()))
|
|
31
18
|
}
|
|
32
19
|
|
|
33
|
-
pub fn gt_eq(&
|
|
34
|
-
|
|
35
|
-
.series
|
|
36
|
-
.borrow()
|
|
37
|
-
.gt_eq(&*rhs.series.borrow())
|
|
38
|
-
.map_err(RbPolarsErr::from)?;
|
|
39
|
-
Ok(Self::new(s.into_series()))
|
|
20
|
+
pub fn gt_eq(rb: &Ruby, self_: &Self, rhs: &RbSeries) -> RbResult<Self> {
|
|
21
|
+
rb.enter_polars_series(|| self_.series.read().gt_eq(&*rhs.series.read()))
|
|
40
22
|
}
|
|
41
23
|
|
|
42
|
-
pub fn lt(&
|
|
43
|
-
|
|
44
|
-
.series
|
|
45
|
-
.borrow()
|
|
46
|
-
.lt(&*rhs.series.borrow())
|
|
47
|
-
.map_err(RbPolarsErr::from)?;
|
|
48
|
-
Ok(Self::new(s.into_series()))
|
|
24
|
+
pub fn lt(rb: &Ruby, self_: &Self, rhs: &RbSeries) -> RbResult<Self> {
|
|
25
|
+
rb.enter_polars_series(|| self_.series.read().lt(&*rhs.series.read()))
|
|
49
26
|
}
|
|
50
27
|
|
|
51
|
-
pub fn lt_eq(&
|
|
52
|
-
|
|
53
|
-
.series
|
|
54
|
-
.borrow()
|
|
55
|
-
.lt_eq(&*rhs.series.borrow())
|
|
56
|
-
.map_err(RbPolarsErr::from)?;
|
|
57
|
-
Ok(Self::new(s.into_series()))
|
|
28
|
+
pub fn lt_eq(rb: &Ruby, self_: &Self, rhs: &RbSeries) -> RbResult<Self> {
|
|
29
|
+
rb.enter_polars_series(|| self_.series.read().lt_eq(&*rhs.series.read()))
|
|
58
30
|
}
|
|
59
31
|
}
|
|
60
32
|
|
|
61
|
-
macro_rules!
|
|
62
|
-
($name:ident, $type:ty) => {
|
|
63
|
-
impl RbSeries {
|
|
64
|
-
pub fn $name(&self, rhs: $type) -> RbResult<Self> {
|
|
65
|
-
let s = self.series.borrow().equal(rhs).map_err(RbPolarsErr::from)?;
|
|
66
|
-
Ok(RbSeries::new(s.into_series()))
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
impl_eq_num!(eq_u8, u8);
|
|
73
|
-
impl_eq_num!(eq_u16, u16);
|
|
74
|
-
impl_eq_num!(eq_u32, u32);
|
|
75
|
-
impl_eq_num!(eq_u64, u64);
|
|
76
|
-
impl_eq_num!(eq_i8, i8);
|
|
77
|
-
impl_eq_num!(eq_i16, i16);
|
|
78
|
-
impl_eq_num!(eq_i32, i32);
|
|
79
|
-
impl_eq_num!(eq_i64, i64);
|
|
80
|
-
impl_eq_num!(eq_f32, f32);
|
|
81
|
-
impl_eq_num!(eq_f64, f64);
|
|
82
|
-
|
|
83
|
-
macro_rules! impl_neq_num {
|
|
84
|
-
($name:ident, $type:ty) => {
|
|
85
|
-
impl RbSeries {
|
|
86
|
-
pub fn $name(&self, rhs: $type) -> RbResult<Self> {
|
|
87
|
-
let s = self
|
|
88
|
-
.series
|
|
89
|
-
.borrow()
|
|
90
|
-
.not_equal(rhs)
|
|
91
|
-
.map_err(RbPolarsErr::from)?;
|
|
92
|
-
Ok(RbSeries::new(s.into_series()))
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
impl_neq_num!(neq_u8, u8);
|
|
99
|
-
impl_neq_num!(neq_u16, u16);
|
|
100
|
-
impl_neq_num!(neq_u32, u32);
|
|
101
|
-
impl_neq_num!(neq_u64, u64);
|
|
102
|
-
impl_neq_num!(neq_i8, i8);
|
|
103
|
-
impl_neq_num!(neq_i16, i16);
|
|
104
|
-
impl_neq_num!(neq_i32, i32);
|
|
105
|
-
impl_neq_num!(neq_i64, i64);
|
|
106
|
-
impl_neq_num!(neq_f32, f32);
|
|
107
|
-
impl_neq_num!(neq_f64, f64);
|
|
108
|
-
|
|
109
|
-
macro_rules! impl_gt_num {
|
|
110
|
-
($name:ident, $type:ty) => {
|
|
111
|
-
impl RbSeries {
|
|
112
|
-
pub fn $name(&self, rhs: $type) -> RbResult<Self> {
|
|
113
|
-
let s = self.series.borrow().gt(rhs).map_err(RbPolarsErr::from)?;
|
|
114
|
-
Ok(RbSeries::new(s.into_series()))
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
impl_gt_num!(gt_u8, u8);
|
|
121
|
-
impl_gt_num!(gt_u16, u16);
|
|
122
|
-
impl_gt_num!(gt_u32, u32);
|
|
123
|
-
impl_gt_num!(gt_u64, u64);
|
|
124
|
-
impl_gt_num!(gt_i8, i8);
|
|
125
|
-
impl_gt_num!(gt_i16, i16);
|
|
126
|
-
impl_gt_num!(gt_i32, i32);
|
|
127
|
-
impl_gt_num!(gt_i64, i64);
|
|
128
|
-
impl_gt_num!(gt_f32, f32);
|
|
129
|
-
impl_gt_num!(gt_f64, f64);
|
|
130
|
-
|
|
131
|
-
macro_rules! impl_gt_eq_num {
|
|
132
|
-
($name:ident, $type:ty) => {
|
|
33
|
+
macro_rules! impl_op {
|
|
34
|
+
($op:ident, $name:ident, $type:ty) => {
|
|
133
35
|
impl RbSeries {
|
|
134
|
-
pub fn $name(&
|
|
135
|
-
|
|
136
|
-
Ok(RbSeries::new(s.into_series()))
|
|
36
|
+
pub fn $name(rb: &Ruby, self_: &Self, rhs: $type) -> RbResult<Self> {
|
|
37
|
+
rb.enter_polars_series(|| self_.series.read().$op(rhs))
|
|
137
38
|
}
|
|
138
39
|
}
|
|
139
40
|
};
|
|
140
41
|
}
|
|
141
42
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
43
|
+
impl_op!(equal, eq_u8, u8);
|
|
44
|
+
impl_op!(equal, eq_u16, u16);
|
|
45
|
+
impl_op!(equal, eq_u32, u32);
|
|
46
|
+
impl_op!(equal, eq_u64, u64);
|
|
47
|
+
impl_op!(equal, eq_i8, i8);
|
|
48
|
+
impl_op!(equal, eq_i16, i16);
|
|
49
|
+
impl_op!(equal, eq_i32, i32);
|
|
50
|
+
impl_op!(equal, eq_i64, i64);
|
|
51
|
+
impl_op!(equal, eq_i128, i128);
|
|
52
|
+
impl_op!(equal, eq_f32, f32);
|
|
53
|
+
impl_op!(equal, eq_f64, f64);
|
|
54
|
+
|
|
55
|
+
impl_op!(not_equal, neq_u8, u8);
|
|
56
|
+
impl_op!(not_equal, neq_u16, u16);
|
|
57
|
+
impl_op!(not_equal, neq_u32, u32);
|
|
58
|
+
impl_op!(not_equal, neq_u64, u64);
|
|
59
|
+
impl_op!(not_equal, neq_i8, i8);
|
|
60
|
+
impl_op!(not_equal, neq_i16, i16);
|
|
61
|
+
impl_op!(not_equal, neq_i32, i32);
|
|
62
|
+
impl_op!(not_equal, neq_i64, i64);
|
|
63
|
+
impl_op!(not_equal, neq_i128, i128);
|
|
64
|
+
impl_op!(not_equal, neq_f32, f32);
|
|
65
|
+
impl_op!(not_equal, neq_f64, f64);
|
|
66
|
+
|
|
67
|
+
impl_op!(gt, gt_u8, u8);
|
|
68
|
+
impl_op!(gt, gt_u16, u16);
|
|
69
|
+
impl_op!(gt, gt_u32, u32);
|
|
70
|
+
impl_op!(gt, gt_u64, u64);
|
|
71
|
+
impl_op!(gt, gt_i8, i8);
|
|
72
|
+
impl_op!(gt, gt_i16, i16);
|
|
73
|
+
impl_op!(gt, gt_i32, i32);
|
|
74
|
+
impl_op!(gt, gt_i64, i64);
|
|
75
|
+
impl_op!(gt, gt_i128, i128);
|
|
76
|
+
impl_op!(gt, gt_f32, f32);
|
|
77
|
+
impl_op!(gt, gt_f64, f64);
|
|
78
|
+
|
|
79
|
+
impl_op!(gt_eq, gt_eq_u8, u8);
|
|
80
|
+
impl_op!(gt_eq, gt_eq_u16, u16);
|
|
81
|
+
impl_op!(gt_eq, gt_eq_u32, u32);
|
|
82
|
+
impl_op!(gt_eq, gt_eq_u64, u64);
|
|
83
|
+
impl_op!(gt_eq, gt_eq_i8, i8);
|
|
84
|
+
impl_op!(gt_eq, gt_eq_i16, i16);
|
|
85
|
+
impl_op!(gt_eq, gt_eq_i32, i32);
|
|
86
|
+
impl_op!(gt_eq, gt_eq_i64, i64);
|
|
87
|
+
impl_op!(gt_eq, gt_eq_i128, i128);
|
|
88
|
+
impl_op!(gt_eq, gt_eq_f32, f32);
|
|
89
|
+
impl_op!(gt_eq, gt_eq_f64, f64);
|
|
90
|
+
|
|
91
|
+
impl_op!(lt, lt_u8, u8);
|
|
92
|
+
impl_op!(lt, lt_u16, u16);
|
|
93
|
+
impl_op!(lt, lt_u32, u32);
|
|
94
|
+
impl_op!(lt, lt_u64, u64);
|
|
95
|
+
impl_op!(lt, lt_i8, i8);
|
|
96
|
+
impl_op!(lt, lt_i16, i16);
|
|
97
|
+
impl_op!(lt, lt_i32, i32);
|
|
98
|
+
impl_op!(lt, lt_i64, i64);
|
|
99
|
+
impl_op!(lt, lt_i128, i128);
|
|
100
|
+
impl_op!(lt, lt_f32, f32);
|
|
101
|
+
impl_op!(lt, lt_f64, f64);
|
|
102
|
+
|
|
103
|
+
impl_op!(lt_eq, lt_eq_u8, u8);
|
|
104
|
+
impl_op!(lt_eq, lt_eq_u16, u16);
|
|
105
|
+
impl_op!(lt_eq, lt_eq_u32, u32);
|
|
106
|
+
impl_op!(lt_eq, lt_eq_u64, u64);
|
|
107
|
+
impl_op!(lt_eq, lt_eq_i8, i8);
|
|
108
|
+
impl_op!(lt_eq, lt_eq_i16, i16);
|
|
109
|
+
impl_op!(lt_eq, lt_eq_i32, i32);
|
|
110
|
+
impl_op!(lt_eq, lt_eq_i64, i64);
|
|
111
|
+
impl_op!(lt_eq, lt_eq_i128, i128);
|
|
112
|
+
impl_op!(lt_eq, lt_eq_f32, f32);
|
|
113
|
+
impl_op!(lt_eq, lt_eq_f64, f64);
|
|
114
|
+
|
|
115
|
+
macro_rules! impl_str {
|
|
116
|
+
($name:ident, $method:ident) => {
|
|
155
117
|
impl RbSeries {
|
|
156
|
-
pub fn $name(&
|
|
157
|
-
|
|
158
|
-
Ok(RbSeries::new(s.into_series()))
|
|
118
|
+
pub fn $name(rb: &Ruby, self_: &Self, rhs: String) -> RbResult<Self> {
|
|
119
|
+
rb.enter_polars_series(|| self_.series.read().$method(rhs.as_str()))
|
|
159
120
|
}
|
|
160
121
|
}
|
|
161
122
|
};
|
|
162
123
|
}
|
|
163
124
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
impl_lt_num!(lt_i32, i32);
|
|
171
|
-
impl_lt_num!(lt_i64, i64);
|
|
172
|
-
impl_lt_num!(lt_f32, f32);
|
|
173
|
-
impl_lt_num!(lt_f64, f64);
|
|
174
|
-
|
|
175
|
-
macro_rules! impl_lt_eq_num {
|
|
176
|
-
($name:ident, $type:ty) => {
|
|
177
|
-
impl RbSeries {
|
|
178
|
-
pub fn $name(&self, rhs: $type) -> RbResult<Self> {
|
|
179
|
-
let s = self.series.borrow().lt_eq(rhs).map_err(RbPolarsErr::from)?;
|
|
180
|
-
Ok(RbSeries::new(s.into_series()))
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
impl_lt_eq_num!(lt_eq_u8, u8);
|
|
187
|
-
impl_lt_eq_num!(lt_eq_u16, u16);
|
|
188
|
-
impl_lt_eq_num!(lt_eq_u32, u32);
|
|
189
|
-
impl_lt_eq_num!(lt_eq_u64, u64);
|
|
190
|
-
impl_lt_eq_num!(lt_eq_i8, i8);
|
|
191
|
-
impl_lt_eq_num!(lt_eq_i16, i16);
|
|
192
|
-
impl_lt_eq_num!(lt_eq_i32, i32);
|
|
193
|
-
impl_lt_eq_num!(lt_eq_i64, i64);
|
|
194
|
-
impl_lt_eq_num!(lt_eq_f32, f32);
|
|
195
|
-
impl_lt_eq_num!(lt_eq_f64, f64);
|
|
196
|
-
|
|
197
|
-
impl RbSeries {
|
|
198
|
-
pub fn eq_str(&self, rhs: String) -> RbResult<Self> {
|
|
199
|
-
let s = self
|
|
200
|
-
.series
|
|
201
|
-
.borrow()
|
|
202
|
-
.equal(rhs.as_str())
|
|
203
|
-
.map_err(RbPolarsErr::from)?;
|
|
204
|
-
Ok(RbSeries::new(s.into_series()))
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
pub fn neq_str(&self, rhs: String) -> RbResult<Self> {
|
|
208
|
-
let s = self
|
|
209
|
-
.series
|
|
210
|
-
.borrow()
|
|
211
|
-
.not_equal(rhs.as_str())
|
|
212
|
-
.map_err(RbPolarsErr::from)?;
|
|
213
|
-
Ok(RbSeries::new(s.into_series()))
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
pub fn gt_str(&self, rhs: String) -> RbResult<Self> {
|
|
217
|
-
let s = self
|
|
218
|
-
.series
|
|
219
|
-
.borrow()
|
|
220
|
-
.gt(rhs.as_str())
|
|
221
|
-
.map_err(RbPolarsErr::from)?;
|
|
222
|
-
Ok(RbSeries::new(s.into_series()))
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
pub fn gt_eq_str(&self, rhs: String) -> RbResult<Self> {
|
|
226
|
-
let s = self
|
|
227
|
-
.series
|
|
228
|
-
.borrow()
|
|
229
|
-
.gt_eq(rhs.as_str())
|
|
230
|
-
.map_err(RbPolarsErr::from)?;
|
|
231
|
-
Ok(RbSeries::new(s.into_series()))
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
pub fn lt_str(&self, rhs: String) -> RbResult<Self> {
|
|
235
|
-
let s = self
|
|
236
|
-
.series
|
|
237
|
-
.borrow()
|
|
238
|
-
.lt(rhs.as_str())
|
|
239
|
-
.map_err(RbPolarsErr::from)?;
|
|
240
|
-
Ok(RbSeries::new(s.into_series()))
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
pub fn lt_eq_str(&self, rhs: String) -> RbResult<Self> {
|
|
244
|
-
let s = self
|
|
245
|
-
.series
|
|
246
|
-
.borrow()
|
|
247
|
-
.lt_eq(rhs.as_str())
|
|
248
|
-
.map_err(RbPolarsErr::from)?;
|
|
249
|
-
Ok(RbSeries::new(s.into_series()))
|
|
250
|
-
}
|
|
251
|
-
}
|
|
125
|
+
impl_str!(eq_str, equal);
|
|
126
|
+
impl_str!(neq_str, not_equal);
|
|
127
|
+
impl_str!(gt_str, gt);
|
|
128
|
+
impl_str!(gt_eq_str, gt_eq);
|
|
129
|
+
impl_str!(lt_str, lt);
|
|
130
|
+
impl_str!(lt_eq_str, lt_eq);
|
|
@@ -4,7 +4,6 @@ use polars_core::prelude::*;
|
|
|
4
4
|
use crate::any_value::rb_object_to_any_value;
|
|
5
5
|
use crate::conversion::{Wrap, slice_extract_wrapped, vec_extract_wrapped};
|
|
6
6
|
use crate::prelude::ObjectValue;
|
|
7
|
-
use crate::series::to_series;
|
|
8
7
|
use crate::{RbPolarsErr, RbResult, RbSeries, RbTypeError, RbValueError};
|
|
9
8
|
|
|
10
9
|
impl RbSeries {
|
|
@@ -190,9 +189,23 @@ impl RbSeries {
|
|
|
190
189
|
Ok(s.into())
|
|
191
190
|
}
|
|
192
191
|
|
|
193
|
-
pub fn new_series_list(name: String,
|
|
194
|
-
let
|
|
195
|
-
|
|
192
|
+
pub fn new_series_list(name: String, values: RArray, _strict: bool) -> RbResult<Self> {
|
|
193
|
+
let series: Vec<_> = values
|
|
194
|
+
.into_iter()
|
|
195
|
+
.map(|ops| {
|
|
196
|
+
Option::<&RbSeries>::try_convert(ops)
|
|
197
|
+
.unwrap()
|
|
198
|
+
.map(|ps| ps.clone().series.into_inner())
|
|
199
|
+
})
|
|
200
|
+
.collect();
|
|
201
|
+
if let Some(s) = series.iter().flatten().next()
|
|
202
|
+
&& s.dtype().is_object()
|
|
203
|
+
{
|
|
204
|
+
return Err(RbValueError::new_err(
|
|
205
|
+
"list of objects isn't supported; try building a 'object' only series",
|
|
206
|
+
));
|
|
207
|
+
}
|
|
208
|
+
Ok(Series::new(name.into(), series).into())
|
|
196
209
|
}
|
|
197
210
|
|
|
198
211
|
pub fn new_array(
|
|
@@ -224,18 +237,4 @@ impl RbSeries {
|
|
|
224
237
|
pub fn new_decimal(name: String, values: RArray, strict: bool) -> RbResult<Self> {
|
|
225
238
|
Self::new_from_any_values(name, values, strict)
|
|
226
239
|
}
|
|
227
|
-
|
|
228
|
-
pub fn repeat(
|
|
229
|
-
name: String,
|
|
230
|
-
val: Wrap<AnyValue>,
|
|
231
|
-
n: usize,
|
|
232
|
-
dtype: Wrap<DataType>,
|
|
233
|
-
) -> RbResult<Self> {
|
|
234
|
-
let av = val.0;
|
|
235
|
-
Ok(Series::new(name.into(), &[av])
|
|
236
|
-
.cast(&dtype.0)
|
|
237
|
-
.map_err(RbPolarsErr::from)?
|
|
238
|
-
.new_from_index(0, n)
|
|
239
|
-
.into())
|
|
240
|
-
}
|
|
241
240
|
}
|
|
@@ -8,7 +8,7 @@ impl RbSeries {
|
|
|
8
8
|
/// Convert this Series to a Ruby array.
|
|
9
9
|
/// This operation copies data.
|
|
10
10
|
pub fn to_a(&self) -> Value {
|
|
11
|
-
let series = &self.series.
|
|
11
|
+
let series = &self.series.read();
|
|
12
12
|
|
|
13
13
|
fn to_a_recursive(series: &Series) -> Value {
|
|
14
14
|
let ruby = Ruby::get().unwrap();
|