polars-df 0.10.0 → 0.12.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 +27 -0
- data/Cargo.lock +392 -351
- data/README.md +6 -6
- data/ext/polars/Cargo.toml +12 -7
- data/ext/polars/src/batched_csv.rs +53 -52
- data/ext/polars/src/conversion/any_value.rs +261 -0
- data/ext/polars/src/conversion/chunked_array.rs +4 -4
- data/ext/polars/src/conversion/mod.rs +60 -66
- data/ext/polars/src/dataframe/construction.rs +184 -0
- data/ext/polars/src/dataframe/export.rs +48 -0
- data/ext/polars/src/dataframe/general.rs +597 -0
- data/ext/polars/src/dataframe/io.rs +473 -0
- data/ext/polars/src/dataframe/mod.rs +26 -0
- data/ext/polars/src/error.rs +26 -4
- data/ext/polars/src/expr/categorical.rs +0 -10
- data/ext/polars/src/expr/datetime.rs +4 -8
- data/ext/polars/src/expr/general.rs +129 -94
- data/ext/polars/src/expr/mod.rs +2 -2
- data/ext/polars/src/expr/rolling.rs +201 -77
- data/ext/polars/src/expr/string.rs +11 -36
- data/ext/polars/src/functions/eager.rs +10 -10
- data/ext/polars/src/functions/lazy.rs +23 -21
- data/ext/polars/src/functions/range.rs +69 -1
- data/ext/polars/src/interop/mod.rs +1 -0
- data/ext/polars/src/interop/numo/mod.rs +2 -0
- data/ext/polars/src/interop/numo/to_numo_df.rs +23 -0
- data/ext/polars/src/interop/numo/to_numo_series.rs +61 -0
- data/ext/polars/src/lazyframe/mod.rs +135 -136
- data/ext/polars/src/lib.rs +94 -59
- data/ext/polars/src/map/dataframe.rs +2 -2
- data/ext/polars/src/map/lazy.rs +5 -25
- data/ext/polars/src/map/series.rs +7 -1
- data/ext/polars/src/rb_modules.rs +25 -1
- data/ext/polars/src/series/aggregation.rs +49 -30
- data/ext/polars/src/series/arithmetic.rs +21 -11
- data/ext/polars/src/series/construction.rs +56 -38
- data/ext/polars/src/series/export.rs +131 -49
- data/ext/polars/src/series/mod.rs +32 -141
- data/ext/polars/src/sql.rs +3 -1
- data/lib/polars/array_expr.rb +4 -4
- data/lib/polars/batched_csv_reader.rb +11 -5
- data/lib/polars/cat_expr.rb +0 -36
- data/lib/polars/cat_name_space.rb +0 -37
- data/lib/polars/convert.rb +6 -1
- data/lib/polars/data_frame.rb +176 -403
- data/lib/polars/data_types.rb +1 -1
- data/lib/polars/date_time_expr.rb +525 -572
- data/lib/polars/date_time_name_space.rb +263 -460
- data/lib/polars/dynamic_group_by.rb +5 -5
- data/lib/polars/exceptions.rb +7 -0
- data/lib/polars/expr.rb +1394 -243
- data/lib/polars/expr_dispatch.rb +1 -1
- data/lib/polars/functions/aggregation/horizontal.rb +8 -8
- data/lib/polars/functions/as_datatype.rb +63 -40
- data/lib/polars/functions/lazy.rb +63 -14
- data/lib/polars/functions/lit.rb +1 -1
- data/lib/polars/functions/range/date_range.rb +90 -57
- data/lib/polars/functions/range/datetime_range.rb +149 -0
- data/lib/polars/functions/range/int_range.rb +2 -2
- data/lib/polars/functions/range/time_range.rb +141 -0
- data/lib/polars/functions/repeat.rb +1 -1
- data/lib/polars/functions/whenthen.rb +1 -1
- data/lib/polars/group_by.rb +88 -23
- data/lib/polars/io/avro.rb +24 -0
- data/lib/polars/{io.rb → io/csv.rb} +299 -493
- data/lib/polars/io/database.rb +73 -0
- data/lib/polars/io/ipc.rb +247 -0
- data/lib/polars/io/json.rb +29 -0
- data/lib/polars/io/ndjson.rb +80 -0
- data/lib/polars/io/parquet.rb +227 -0
- data/lib/polars/lazy_frame.rb +143 -272
- data/lib/polars/lazy_group_by.rb +100 -3
- data/lib/polars/list_expr.rb +11 -11
- data/lib/polars/list_name_space.rb +5 -1
- data/lib/polars/rolling_group_by.rb +7 -9
- data/lib/polars/series.rb +103 -187
- data/lib/polars/string_expr.rb +78 -102
- data/lib/polars/string_name_space.rb +5 -4
- data/lib/polars/testing.rb +2 -2
- data/lib/polars/utils/constants.rb +9 -0
- data/lib/polars/utils/convert.rb +97 -0
- data/lib/polars/utils/parse.rb +89 -0
- data/lib/polars/utils/various.rb +76 -0
- data/lib/polars/utils/wrap.rb +19 -0
- data/lib/polars/utils.rb +8 -300
- data/lib/polars/version.rb +1 -1
- data/lib/polars/whenthen.rb +6 -6
- data/lib/polars.rb +20 -1
- metadata +28 -7
- data/ext/polars/src/conversion/anyvalue.rs +0 -186
- data/ext/polars/src/dataframe.rs +0 -1208
@@ -7,187 +7,289 @@ use crate::RbExpr;
|
|
7
7
|
impl RbExpr {
|
8
8
|
pub fn rolling_sum(
|
9
9
|
&self,
|
10
|
-
window_size:
|
10
|
+
window_size: usize,
|
11
11
|
weights: Option<Vec<f64>>,
|
12
|
-
min_periods: usize
|
12
|
+
min_periods: Option<usize>,
|
13
13
|
center: bool,
|
14
|
-
by: Option<String>,
|
15
|
-
closed: Option<Wrap<ClosedWindow>>,
|
16
14
|
) -> Self {
|
17
|
-
let
|
18
|
-
|
15
|
+
let min_periods = min_periods.unwrap_or(window_size);
|
16
|
+
let options = RollingOptionsFixedWindow {
|
17
|
+
window_size,
|
19
18
|
weights,
|
20
19
|
min_periods,
|
21
20
|
center,
|
22
|
-
by,
|
23
|
-
closed_window: closed.map(|c| c.0),
|
24
21
|
..Default::default()
|
25
22
|
};
|
26
23
|
self.inner.clone().rolling_sum(options).into()
|
27
24
|
}
|
28
25
|
|
29
|
-
pub fn
|
26
|
+
pub fn rolling_sum_by(
|
30
27
|
&self,
|
28
|
+
by: &RbExpr,
|
31
29
|
window_size: String,
|
32
|
-
weights: Option<Vec<f64>>,
|
33
30
|
min_periods: usize,
|
34
|
-
|
35
|
-
by: Option<String>,
|
36
|
-
closed: Option<Wrap<ClosedWindow>>,
|
31
|
+
closed: Wrap<ClosedWindow>,
|
37
32
|
) -> Self {
|
38
|
-
let options =
|
33
|
+
let options = RollingOptionsDynamicWindow {
|
39
34
|
window_size: Duration::parse(&window_size),
|
35
|
+
min_periods,
|
36
|
+
closed_window: closed.0,
|
37
|
+
fn_params: None,
|
38
|
+
};
|
39
|
+
self.inner
|
40
|
+
.clone()
|
41
|
+
.rolling_sum_by(by.inner.clone(), options)
|
42
|
+
.into()
|
43
|
+
}
|
44
|
+
|
45
|
+
pub fn rolling_min(
|
46
|
+
&self,
|
47
|
+
window_size: usize,
|
48
|
+
weights: Option<Vec<f64>>,
|
49
|
+
min_periods: Option<usize>,
|
50
|
+
center: bool,
|
51
|
+
) -> Self {
|
52
|
+
let min_periods = min_periods.unwrap_or(window_size);
|
53
|
+
let options = RollingOptionsFixedWindow {
|
54
|
+
window_size,
|
40
55
|
weights,
|
41
56
|
min_periods,
|
42
57
|
center,
|
43
|
-
by,
|
44
|
-
closed_window: closed.map(|c| c.0),
|
45
58
|
..Default::default()
|
46
59
|
};
|
47
60
|
self.inner.clone().rolling_min(options).into()
|
48
61
|
}
|
49
62
|
|
50
|
-
pub fn
|
63
|
+
pub fn rolling_min_by(
|
51
64
|
&self,
|
65
|
+
by: &RbExpr,
|
52
66
|
window_size: String,
|
53
|
-
weights: Option<Vec<f64>>,
|
54
67
|
min_periods: usize,
|
55
|
-
|
56
|
-
by: Option<String>,
|
57
|
-
closed: Option<Wrap<ClosedWindow>>,
|
68
|
+
closed: Wrap<ClosedWindow>,
|
58
69
|
) -> Self {
|
59
|
-
let options =
|
70
|
+
let options = RollingOptionsDynamicWindow {
|
60
71
|
window_size: Duration::parse(&window_size),
|
72
|
+
min_periods,
|
73
|
+
closed_window: closed.0,
|
74
|
+
fn_params: None,
|
75
|
+
};
|
76
|
+
self.inner
|
77
|
+
.clone()
|
78
|
+
.rolling_min_by(by.inner.clone(), options)
|
79
|
+
.into()
|
80
|
+
}
|
81
|
+
|
82
|
+
pub fn rolling_max(
|
83
|
+
&self,
|
84
|
+
window_size: usize,
|
85
|
+
weights: Option<Vec<f64>>,
|
86
|
+
min_periods: Option<usize>,
|
87
|
+
center: bool,
|
88
|
+
) -> Self {
|
89
|
+
let min_periods = min_periods.unwrap_or(window_size);
|
90
|
+
let options = RollingOptionsFixedWindow {
|
91
|
+
window_size,
|
61
92
|
weights,
|
62
93
|
min_periods,
|
63
94
|
center,
|
64
|
-
by,
|
65
|
-
closed_window: closed.map(|c| c.0),
|
66
95
|
..Default::default()
|
67
96
|
};
|
68
97
|
self.inner.clone().rolling_max(options).into()
|
69
98
|
}
|
70
99
|
|
71
|
-
pub fn
|
100
|
+
pub fn rolling_max_by(
|
72
101
|
&self,
|
102
|
+
by: &RbExpr,
|
73
103
|
window_size: String,
|
74
|
-
weights: Option<Vec<f64>>,
|
75
104
|
min_periods: usize,
|
76
|
-
|
77
|
-
by: Option<String>,
|
78
|
-
closed: Option<Wrap<ClosedWindow>>,
|
105
|
+
closed: Wrap<ClosedWindow>,
|
79
106
|
) -> Self {
|
80
|
-
let options =
|
107
|
+
let options = RollingOptionsDynamicWindow {
|
81
108
|
window_size: Duration::parse(&window_size),
|
109
|
+
min_periods,
|
110
|
+
closed_window: closed.0,
|
111
|
+
fn_params: None,
|
112
|
+
};
|
113
|
+
self.inner
|
114
|
+
.clone()
|
115
|
+
.rolling_max_by(by.inner.clone(), options)
|
116
|
+
.into()
|
117
|
+
}
|
118
|
+
|
119
|
+
pub fn rolling_mean(
|
120
|
+
&self,
|
121
|
+
window_size: usize,
|
122
|
+
weights: Option<Vec<f64>>,
|
123
|
+
min_periods: Option<usize>,
|
124
|
+
center: bool,
|
125
|
+
) -> Self {
|
126
|
+
let min_periods = min_periods.unwrap_or(window_size);
|
127
|
+
let options = RollingOptionsFixedWindow {
|
128
|
+
window_size,
|
82
129
|
weights,
|
83
130
|
min_periods,
|
84
131
|
center,
|
85
|
-
by,
|
86
|
-
closed_window: closed.map(|c| c.0),
|
87
132
|
..Default::default()
|
88
133
|
};
|
89
134
|
|
90
135
|
self.inner.clone().rolling_mean(options).into()
|
91
136
|
}
|
92
137
|
|
93
|
-
|
94
|
-
pub fn rolling_std(
|
138
|
+
pub fn rolling_mean_by(
|
95
139
|
&self,
|
140
|
+
by: &RbExpr,
|
96
141
|
window_size: String,
|
97
|
-
weights: Option<Vec<f64>>,
|
98
142
|
min_periods: usize,
|
143
|
+
closed: Wrap<ClosedWindow>,
|
144
|
+
) -> Self {
|
145
|
+
let options = RollingOptionsDynamicWindow {
|
146
|
+
window_size: Duration::parse(&window_size),
|
147
|
+
min_periods,
|
148
|
+
closed_window: closed.0,
|
149
|
+
fn_params: None,
|
150
|
+
};
|
151
|
+
|
152
|
+
self.inner
|
153
|
+
.clone()
|
154
|
+
.rolling_mean_by(by.inner.clone(), options)
|
155
|
+
.into()
|
156
|
+
}
|
157
|
+
|
158
|
+
pub fn rolling_std(
|
159
|
+
&self,
|
160
|
+
window_size: usize,
|
161
|
+
weights: Option<Vec<f64>>,
|
162
|
+
min_periods: Option<usize>,
|
99
163
|
center: bool,
|
100
|
-
by: Option<String>,
|
101
|
-
closed: Option<Wrap<ClosedWindow>>,
|
102
164
|
ddof: u8,
|
103
|
-
warn_if_unsorted: bool,
|
104
165
|
) -> Self {
|
105
|
-
let
|
106
|
-
|
166
|
+
let min_periods = min_periods.unwrap_or(window_size);
|
167
|
+
let options = RollingOptionsFixedWindow {
|
168
|
+
window_size,
|
107
169
|
weights,
|
108
170
|
min_periods,
|
109
171
|
center,
|
110
|
-
by,
|
111
|
-
closed_window: closed.map(|c| c.0),
|
112
172
|
fn_params: Some(Arc::new(RollingVarParams { ddof }) as Arc<dyn Any + Send + Sync>),
|
113
|
-
warn_if_unsorted,
|
114
173
|
};
|
115
174
|
|
116
175
|
self.inner.clone().rolling_std(options).into()
|
117
176
|
}
|
118
177
|
|
119
|
-
|
120
|
-
pub fn rolling_var(
|
178
|
+
pub fn rolling_std_by(
|
121
179
|
&self,
|
180
|
+
by: &RbExpr,
|
122
181
|
window_size: String,
|
123
|
-
weights: Option<Vec<f64>>,
|
124
182
|
min_periods: usize,
|
125
|
-
|
126
|
-
by: Option<String>,
|
127
|
-
closed: Option<Wrap<ClosedWindow>>,
|
183
|
+
closed: Wrap<ClosedWindow>,
|
128
184
|
ddof: u8,
|
129
|
-
warn_if_unsorted: bool,
|
130
185
|
) -> Self {
|
131
|
-
let options =
|
186
|
+
let options = RollingOptionsDynamicWindow {
|
132
187
|
window_size: Duration::parse(&window_size),
|
188
|
+
min_periods,
|
189
|
+
closed_window: closed.0,
|
190
|
+
fn_params: Some(Arc::new(RollingVarParams { ddof }) as Arc<dyn Any + Send + Sync>),
|
191
|
+
};
|
192
|
+
|
193
|
+
self.inner
|
194
|
+
.clone()
|
195
|
+
.rolling_std_by(by.inner.clone(), options)
|
196
|
+
.into()
|
197
|
+
}
|
198
|
+
|
199
|
+
pub fn rolling_var(
|
200
|
+
&self,
|
201
|
+
window_size: usize,
|
202
|
+
weights: Option<Vec<f64>>,
|
203
|
+
min_periods: Option<usize>,
|
204
|
+
center: bool,
|
205
|
+
ddof: u8,
|
206
|
+
) -> Self {
|
207
|
+
let min_periods = min_periods.unwrap_or(window_size);
|
208
|
+
let options = RollingOptionsFixedWindow {
|
209
|
+
window_size,
|
133
210
|
weights,
|
134
211
|
min_periods,
|
135
212
|
center,
|
136
|
-
by,
|
137
|
-
closed_window: closed.map(|c| c.0),
|
138
213
|
fn_params: Some(Arc::new(RollingVarParams { ddof }) as Arc<dyn Any + Send + Sync>),
|
139
|
-
warn_if_unsorted,
|
140
214
|
};
|
141
215
|
|
142
216
|
self.inner.clone().rolling_var(options).into()
|
143
217
|
}
|
144
218
|
|
145
|
-
|
146
|
-
pub fn rolling_median(
|
219
|
+
pub fn rolling_var_by(
|
147
220
|
&self,
|
221
|
+
by: &RbExpr,
|
148
222
|
window_size: String,
|
149
|
-
weights: Option<Vec<f64>>,
|
150
223
|
min_periods: usize,
|
151
|
-
|
152
|
-
|
153
|
-
closed: Option<Wrap<ClosedWindow>>,
|
154
|
-
warn_if_unsorted: bool,
|
224
|
+
closed: Wrap<ClosedWindow>,
|
225
|
+
ddof: u8,
|
155
226
|
) -> Self {
|
156
|
-
let options =
|
227
|
+
let options = RollingOptionsDynamicWindow {
|
157
228
|
window_size: Duration::parse(&window_size),
|
158
|
-
weights,
|
159
229
|
min_periods,
|
230
|
+
closed_window: closed.0,
|
231
|
+
fn_params: Some(Arc::new(RollingVarParams { ddof }) as Arc<dyn Any + Send + Sync>),
|
232
|
+
};
|
233
|
+
|
234
|
+
self.inner
|
235
|
+
.clone()
|
236
|
+
.rolling_var_by(by.inner.clone(), options)
|
237
|
+
.into()
|
238
|
+
}
|
239
|
+
|
240
|
+
pub fn rolling_median(
|
241
|
+
&self,
|
242
|
+
window_size: usize,
|
243
|
+
weights: Option<Vec<f64>>,
|
244
|
+
min_periods: Option<usize>,
|
245
|
+
center: bool,
|
246
|
+
) -> Self {
|
247
|
+
let min_periods = min_periods.unwrap_or(window_size);
|
248
|
+
let options = RollingOptionsFixedWindow {
|
249
|
+
window_size,
|
250
|
+
min_periods,
|
251
|
+
weights,
|
160
252
|
center,
|
161
|
-
by,
|
162
|
-
closed_window: closed.map(|c| c.0),
|
163
253
|
fn_params: None,
|
164
|
-
warn_if_unsorted,
|
165
254
|
};
|
166
255
|
self.inner.clone().rolling_median(options).into()
|
167
256
|
}
|
168
257
|
|
169
|
-
|
258
|
+
pub fn rolling_median_by(
|
259
|
+
&self,
|
260
|
+
by: &RbExpr,
|
261
|
+
window_size: String,
|
262
|
+
min_periods: usize,
|
263
|
+
closed: Wrap<ClosedWindow>,
|
264
|
+
) -> Self {
|
265
|
+
let options = RollingOptionsDynamicWindow {
|
266
|
+
window_size: Duration::parse(&window_size),
|
267
|
+
min_periods,
|
268
|
+
closed_window: closed.0,
|
269
|
+
fn_params: None,
|
270
|
+
};
|
271
|
+
self.inner
|
272
|
+
.clone()
|
273
|
+
.rolling_median_by(by.inner.clone(), options)
|
274
|
+
.into()
|
275
|
+
}
|
276
|
+
|
170
277
|
pub fn rolling_quantile(
|
171
278
|
&self,
|
172
279
|
quantile: f64,
|
173
280
|
interpolation: Wrap<QuantileInterpolOptions>,
|
174
|
-
window_size:
|
281
|
+
window_size: usize,
|
175
282
|
weights: Option<Vec<f64>>,
|
176
|
-
min_periods: usize
|
283
|
+
min_periods: Option<usize>,
|
177
284
|
center: bool,
|
178
|
-
by: Option<String>,
|
179
|
-
closed: Option<Wrap<ClosedWindow>>,
|
180
|
-
warn_if_unsorted: bool,
|
181
285
|
) -> Self {
|
182
|
-
let
|
183
|
-
|
286
|
+
let min_periods = min_periods.unwrap_or(window_size);
|
287
|
+
let options = RollingOptionsFixedWindow {
|
288
|
+
window_size,
|
184
289
|
weights,
|
185
290
|
min_periods,
|
186
291
|
center,
|
187
|
-
by,
|
188
|
-
closed_window: closed.map(|c| c.0),
|
189
292
|
fn_params: None,
|
190
|
-
warn_if_unsorted,
|
191
293
|
};
|
192
294
|
|
193
295
|
self.inner
|
@@ -196,6 +298,28 @@ impl RbExpr {
|
|
196
298
|
.into()
|
197
299
|
}
|
198
300
|
|
301
|
+
pub fn rolling_quantile_by(
|
302
|
+
&self,
|
303
|
+
by: &RbExpr,
|
304
|
+
quantile: f64,
|
305
|
+
interpolation: Wrap<QuantileInterpolOptions>,
|
306
|
+
window_size: String,
|
307
|
+
min_periods: usize,
|
308
|
+
closed: Wrap<ClosedWindow>,
|
309
|
+
) -> Self {
|
310
|
+
let options = RollingOptionsDynamicWindow {
|
311
|
+
window_size: Duration::parse(&window_size),
|
312
|
+
min_periods,
|
313
|
+
closed_window: closed.0,
|
314
|
+
fn_params: None,
|
315
|
+
};
|
316
|
+
|
317
|
+
self.inner
|
318
|
+
.clone()
|
319
|
+
.rolling_quantile_by(by.inner.clone(), interpolation.0, quantile, options)
|
320
|
+
.into()
|
321
|
+
}
|
322
|
+
|
199
323
|
pub fn rolling_skew(&self, window_size: usize, bias: bool) -> Self {
|
200
324
|
self.inner.clone().rolling_skew(window_size, bias).into()
|
201
325
|
}
|
@@ -4,11 +4,11 @@ use crate::conversion::Wrap;
|
|
4
4
|
use crate::{RbExpr, RbPolarsErr, RbResult};
|
5
5
|
|
6
6
|
impl RbExpr {
|
7
|
-
pub fn
|
7
|
+
pub fn str_join(&self, delimiter: String, ignore_nulls: bool) -> Self {
|
8
8
|
self.inner
|
9
9
|
.clone()
|
10
10
|
.str()
|
11
|
-
.
|
11
|
+
.join(&delimiter, ignore_nulls)
|
12
12
|
.into()
|
13
13
|
}
|
14
14
|
|
@@ -115,10 +115,6 @@ impl RbExpr {
|
|
115
115
|
.into()
|
116
116
|
}
|
117
117
|
|
118
|
-
pub fn str_explode(&self) -> Self {
|
119
|
-
self.inner.clone().str().explode().into()
|
120
|
-
}
|
121
|
-
|
122
118
|
pub fn str_to_uppercase(&self) -> Self {
|
123
119
|
self.inner.clone().str().to_uppercase().into()
|
124
120
|
}
|
@@ -259,39 +255,18 @@ impl RbExpr {
|
|
259
255
|
infer_schema_len: Option<usize>,
|
260
256
|
) -> Self {
|
261
257
|
let dtype = dtype.map(|wrap| wrap.0);
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
};
|
267
|
-
|
268
|
-
let function = move |s: Series| {
|
269
|
-
let ca = s.str()?;
|
270
|
-
match ca.json_decode(dtype.clone(), infer_schema_len) {
|
271
|
-
Ok(ca) => Ok(Some(ca.into_series())),
|
272
|
-
Err(e) => Err(PolarsError::ComputeError(format!("{e:?}").into())),
|
273
|
-
}
|
274
|
-
};
|
275
|
-
|
276
|
-
self.clone()
|
277
|
-
.inner
|
278
|
-
.map(function, output_type)
|
279
|
-
.with_fmt("str.json_decode")
|
258
|
+
self.inner
|
259
|
+
.clone()
|
260
|
+
.str()
|
261
|
+
.json_decode(dtype, infer_schema_len)
|
280
262
|
.into()
|
281
263
|
}
|
282
264
|
|
283
|
-
pub fn str_json_path_match(&self, pat:
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
Err(e) => Err(PolarsError::ComputeError(format!("{:?}", e).into())),
|
289
|
-
}
|
290
|
-
};
|
291
|
-
self.clone()
|
292
|
-
.inner
|
293
|
-
.map(function, GetOutput::from_type(DataType::String))
|
294
|
-
.with_fmt("str.json_path_match")
|
265
|
+
pub fn str_json_path_match(&self, pat: &Self) -> Self {
|
266
|
+
self.inner
|
267
|
+
.clone()
|
268
|
+
.str()
|
269
|
+
.json_path_match(pat.inner.clone())
|
295
270
|
.into()
|
296
271
|
}
|
297
272
|
|
@@ -9,8 +9,8 @@ use crate::{RbDataFrame, RbResult, RbSeries};
|
|
9
9
|
pub fn concat_df(seq: RArray) -> RbResult<RbDataFrame> {
|
10
10
|
use polars_core::error::PolarsResult;
|
11
11
|
|
12
|
-
let mut iter = seq.
|
13
|
-
let first = iter.next().unwrap()
|
12
|
+
let mut iter = seq.into_iter();
|
13
|
+
let first = iter.next().unwrap();
|
14
14
|
|
15
15
|
let first_rdf = get_df(first)?;
|
16
16
|
let identity_df = first_rdf.slice(0, 0);
|
@@ -18,7 +18,7 @@ pub fn concat_df(seq: RArray) -> RbResult<RbDataFrame> {
|
|
18
18
|
let mut rdfs: Vec<PolarsResult<DataFrame>> = vec![Ok(first_rdf)];
|
19
19
|
|
20
20
|
for item in iter {
|
21
|
-
let rdf = get_df(item
|
21
|
+
let rdf = get_df(item)?;
|
22
22
|
rdfs.push(Ok(rdf));
|
23
23
|
}
|
24
24
|
|
@@ -37,13 +37,13 @@ pub fn concat_df(seq: RArray) -> RbResult<RbDataFrame> {
|
|
37
37
|
}
|
38
38
|
|
39
39
|
pub fn concat_series(seq: RArray) -> RbResult<RbSeries> {
|
40
|
-
let mut iter = seq.
|
41
|
-
let first = iter.next().unwrap()
|
40
|
+
let mut iter = seq.into_iter();
|
41
|
+
let first = iter.next().unwrap();
|
42
42
|
|
43
43
|
let mut s = get_series(first)?;
|
44
44
|
|
45
45
|
for res in iter {
|
46
|
-
let item = res
|
46
|
+
let item = res;
|
47
47
|
let item = get_series(item)?;
|
48
48
|
s.append(&item).map_err(RbPolarsErr::from)?;
|
49
49
|
}
|
@@ -52,8 +52,8 @@ pub fn concat_series(seq: RArray) -> RbResult<RbSeries> {
|
|
52
52
|
|
53
53
|
pub fn concat_df_diagonal(seq: RArray) -> RbResult<RbDataFrame> {
|
54
54
|
let mut dfs = Vec::new();
|
55
|
-
for item in seq.
|
56
|
-
dfs.push(get_df(item
|
55
|
+
for item in seq.into_iter() {
|
56
|
+
dfs.push(get_df(item)?);
|
57
57
|
}
|
58
58
|
let df = functions::concat_df_diagonal(&dfs).map_err(RbPolarsErr::from)?;
|
59
59
|
Ok(df.into())
|
@@ -61,8 +61,8 @@ pub fn concat_df_diagonal(seq: RArray) -> RbResult<RbDataFrame> {
|
|
61
61
|
|
62
62
|
pub fn concat_df_horizontal(seq: RArray) -> RbResult<RbDataFrame> {
|
63
63
|
let mut dfs = Vec::new();
|
64
|
-
for item in seq.
|
65
|
-
dfs.push(get_df(item
|
64
|
+
for item in seq.into_iter() {
|
65
|
+
dfs.push(get_df(item)?);
|
66
66
|
}
|
67
67
|
let df = functions::concat_df_horizontal(&dfs).map_err(RbPolarsErr::from)?;
|
68
68
|
Ok(df.into())
|
@@ -58,7 +58,7 @@ pub fn rolling_cov(
|
|
58
58
|
pub fn arg_sort_by(
|
59
59
|
by: RArray,
|
60
60
|
descending: Vec<bool>,
|
61
|
-
nulls_last: bool
|
61
|
+
nulls_last: Vec<bool>,
|
62
62
|
multithreaded: bool,
|
63
63
|
maintain_order: bool,
|
64
64
|
) -> RbResult<RbExpr> {
|
@@ -95,12 +95,12 @@ pub fn col(name: String) -> RbExpr {
|
|
95
95
|
|
96
96
|
pub fn collect_all(lfs: RArray) -> RbResult<RArray> {
|
97
97
|
let lfs = lfs
|
98
|
-
.
|
99
|
-
.map(
|
98
|
+
.into_iter()
|
99
|
+
.map(<&RbLazyFrame>::try_convert)
|
100
100
|
.collect::<RbResult<Vec<&RbLazyFrame>>>()?;
|
101
101
|
|
102
102
|
Ok(RArray::from_iter(lfs.iter().map(|lf| {
|
103
|
-
let df = lf.ldf.clone().collect().unwrap();
|
103
|
+
let df = lf.ldf.borrow().clone().collect().unwrap();
|
104
104
|
RbDataFrame::new(df)
|
105
105
|
})))
|
106
106
|
}
|
@@ -118,8 +118,8 @@ pub fn concat_lf(
|
|
118
118
|
let (seq, len) = get_rbseq(lfs)?;
|
119
119
|
let mut lfs = Vec::with_capacity(len);
|
120
120
|
|
121
|
-
for res in seq.
|
122
|
-
let item = res
|
121
|
+
for res in seq.into_iter() {
|
122
|
+
let item = res;
|
123
123
|
let lf = get_lf(item)?;
|
124
124
|
lfs.push(lf);
|
125
125
|
}
|
@@ -130,6 +130,7 @@ pub fn concat_lf(
|
|
130
130
|
rechunk,
|
131
131
|
parallel,
|
132
132
|
to_supertypes,
|
133
|
+
..Default::default()
|
133
134
|
},
|
134
135
|
)
|
135
136
|
.map_err(RbPolarsErr::from)?;
|
@@ -183,14 +184,9 @@ pub fn concat_lf_diagonal(
|
|
183
184
|
parallel: bool,
|
184
185
|
to_supertypes: bool,
|
185
186
|
) -> RbResult<RbLazyFrame> {
|
186
|
-
let iter = lfs.
|
187
|
+
let iter = lfs.into_iter();
|
187
188
|
|
188
|
-
let lfs = iter
|
189
|
-
.map(|item| {
|
190
|
-
let item = item?;
|
191
|
-
get_lf(item)
|
192
|
-
})
|
193
|
-
.collect::<RbResult<Vec<_>>>()?;
|
189
|
+
let lfs = iter.map(get_lf).collect::<RbResult<Vec<_>>>()?;
|
194
190
|
|
195
191
|
let lf = dsl::functions::concat_lf_diagonal(
|
196
192
|
lfs,
|
@@ -198,23 +194,29 @@ pub fn concat_lf_diagonal(
|
|
198
194
|
rechunk,
|
199
195
|
parallel,
|
200
196
|
to_supertypes,
|
197
|
+
..Default::default()
|
201
198
|
},
|
202
199
|
)
|
203
200
|
.map_err(RbPolarsErr::from)?;
|
204
201
|
Ok(lf.into())
|
205
202
|
}
|
206
203
|
|
207
|
-
pub fn dtype_cols(dtypes:
|
208
|
-
dsl::dtype_cols(dtypes).into()
|
209
|
-
}
|
210
|
-
|
211
|
-
pub fn dtype_cols2(dtypes: RArray) -> RbResult<RbExpr> {
|
204
|
+
pub fn dtype_cols(dtypes: RArray) -> RbResult<RbExpr> {
|
212
205
|
let dtypes = dtypes
|
213
|
-
.
|
214
|
-
.map(
|
206
|
+
.into_iter()
|
207
|
+
.map(Wrap::<DataType>::try_convert)
|
215
208
|
.collect::<RbResult<Vec<Wrap<DataType>>>>()?;
|
216
209
|
let dtypes = vec_extract_wrapped(dtypes);
|
217
|
-
Ok(
|
210
|
+
Ok(dsl::dtype_cols(dtypes).into())
|
211
|
+
}
|
212
|
+
|
213
|
+
pub fn index_cols(indices: Vec<i64>) -> RbExpr {
|
214
|
+
if indices.len() == 1 {
|
215
|
+
dsl::nth(indices[0])
|
216
|
+
} else {
|
217
|
+
dsl::index_cols(indices)
|
218
|
+
}
|
219
|
+
.into()
|
218
220
|
}
|
219
221
|
|
220
222
|
#[allow(clippy::too_many_arguments)]
|