polars-df 0.13.0 → 0.14.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 +5 -0
- data/Cargo.lock +177 -141
- data/ext/polars/Cargo.toml +5 -6
- data/ext/polars/src/batched_csv.rs +3 -3
- data/ext/polars/src/conversion/any_value.rs +10 -4
- data/ext/polars/src/conversion/chunked_array.rs +3 -3
- data/ext/polars/src/conversion/mod.rs +36 -20
- data/ext/polars/src/dataframe/construction.rs +4 -4
- data/ext/polars/src/dataframe/general.rs +6 -5
- data/ext/polars/src/dataframe/io.rs +6 -6
- data/ext/polars/src/expr/datetime.rs +11 -3
- data/ext/polars/src/expr/general.rs +1 -1
- data/ext/polars/src/expr/name.rs +3 -2
- data/ext/polars/src/expr/string.rs +8 -1
- data/ext/polars/src/functions/io.rs +6 -6
- data/ext/polars/src/functions/range.rs +4 -2
- data/ext/polars/src/lazyframe/mod.rs +18 -16
- data/ext/polars/src/lib.rs +1 -1
- data/ext/polars/src/map/dataframe.rs +36 -8
- data/ext/polars/src/map/mod.rs +8 -8
- data/ext/polars/src/map/series.rs +106 -64
- data/ext/polars/src/on_startup.rs +1 -1
- data/ext/polars/src/series/construction.rs +50 -23
- data/ext/polars/src/series/mod.rs +4 -4
- data/lib/polars/data_frame.rb +10 -10
- data/lib/polars/expr.rb +6 -6
- data/lib/polars/io/ipc.rb +0 -8
- data/lib/polars/series.rb +5 -5
- data/lib/polars/version.rb +1 -1
- metadata +3 -3
@@ -158,10 +158,16 @@ where
|
|
158
158
|
{
|
159
159
|
let skip = usize::from(first_value.is_some());
|
160
160
|
if init_null_count == df.height() {
|
161
|
-
ChunkedArray::full_null("
|
161
|
+
ChunkedArray::full_null(PlSmallStr::from_static("map"), df.height())
|
162
162
|
} else {
|
163
163
|
let iter = apply_iter(df, lambda, init_null_count, skip);
|
164
|
-
iterator_to_primitive(
|
164
|
+
iterator_to_primitive(
|
165
|
+
iter,
|
166
|
+
init_null_count,
|
167
|
+
first_value,
|
168
|
+
PlSmallStr::from_static("map"),
|
169
|
+
df.height(),
|
170
|
+
)
|
165
171
|
}
|
166
172
|
}
|
167
173
|
|
@@ -174,10 +180,16 @@ pub fn apply_lambda_with_bool_out_type(
|
|
174
180
|
) -> ChunkedArray<BooleanType> {
|
175
181
|
let skip = usize::from(first_value.is_some());
|
176
182
|
if init_null_count == df.height() {
|
177
|
-
ChunkedArray::full_null("
|
183
|
+
ChunkedArray::full_null(PlSmallStr::from_static("map"), df.height())
|
178
184
|
} else {
|
179
185
|
let iter = apply_iter(df, lambda, init_null_count, skip);
|
180
|
-
iterator_to_bool(
|
186
|
+
iterator_to_bool(
|
187
|
+
iter,
|
188
|
+
init_null_count,
|
189
|
+
first_value,
|
190
|
+
PlSmallStr::from_static("map"),
|
191
|
+
df.height(),
|
192
|
+
)
|
181
193
|
}
|
182
194
|
}
|
183
195
|
|
@@ -190,10 +202,16 @@ pub fn apply_lambda_with_utf8_out_type(
|
|
190
202
|
) -> StringChunked {
|
191
203
|
let skip = usize::from(first_value.is_some());
|
192
204
|
if init_null_count == df.height() {
|
193
|
-
ChunkedArray::full_null("
|
205
|
+
ChunkedArray::full_null(PlSmallStr::from_static("map"), df.height())
|
194
206
|
} else {
|
195
207
|
let iter = apply_iter::<String>(df, lambda, init_null_count, skip);
|
196
|
-
iterator_to_utf8(
|
208
|
+
iterator_to_utf8(
|
209
|
+
iter,
|
210
|
+
init_null_count,
|
211
|
+
first_value,
|
212
|
+
PlSmallStr::from_static("map"),
|
213
|
+
df.height(),
|
214
|
+
)
|
197
215
|
}
|
198
216
|
}
|
199
217
|
|
@@ -207,7 +225,10 @@ pub fn apply_lambda_with_list_out_type(
|
|
207
225
|
) -> RbResult<ListChunked> {
|
208
226
|
let skip = usize::from(first_value.is_some());
|
209
227
|
if init_null_count == df.height() {
|
210
|
-
Ok(ChunkedArray::full_null(
|
228
|
+
Ok(ChunkedArray::full_null(
|
229
|
+
PlSmallStr::from_static("map"),
|
230
|
+
df.height(),
|
231
|
+
))
|
211
232
|
} else {
|
212
233
|
let mut iters = get_iters_skip(df, init_null_count + skip);
|
213
234
|
let iter = ((init_null_count + skip)..df.height()).map(|_| {
|
@@ -229,7 +250,14 @@ pub fn apply_lambda_with_list_out_type(
|
|
229
250
|
Err(e) => panic!("ruby function failed {}", e),
|
230
251
|
}
|
231
252
|
});
|
232
|
-
iterator_to_list(
|
253
|
+
iterator_to_list(
|
254
|
+
dt,
|
255
|
+
iter,
|
256
|
+
init_null_count,
|
257
|
+
first_value,
|
258
|
+
PlSmallStr::from_static("map"),
|
259
|
+
df.height(),
|
260
|
+
)
|
233
261
|
}
|
234
262
|
}
|
235
263
|
|
data/ext/polars/src/map/mod.rs
CHANGED
@@ -28,7 +28,7 @@ fn iterator_to_struct(
|
|
28
28
|
it: impl Iterator<Item = Option<Value>>,
|
29
29
|
init_null_count: usize,
|
30
30
|
first_value: AnyValue,
|
31
|
-
name:
|
31
|
+
name: PlSmallStr,
|
32
32
|
capacity: usize,
|
33
33
|
) -> RbResult<RbSeries> {
|
34
34
|
let (vals, flds) = match &first_value {
|
@@ -89,7 +89,7 @@ fn iterator_to_struct(
|
|
89
89
|
items
|
90
90
|
.par_iter()
|
91
91
|
.zip(flds)
|
92
|
-
.map(|(av, fld)| Series::new(fld.name(), av))
|
92
|
+
.map(|(av, fld)| Series::new(fld.name().clone(), av))
|
93
93
|
.collect::<Vec<_>>()
|
94
94
|
});
|
95
95
|
|
@@ -103,7 +103,7 @@ fn iterator_to_primitive<T>(
|
|
103
103
|
it: impl Iterator<Item = Option<T::Native>>,
|
104
104
|
init_null_count: usize,
|
105
105
|
first_value: Option<T::Native>,
|
106
|
-
name:
|
106
|
+
name: PlSmallStr,
|
107
107
|
capacity: usize,
|
108
108
|
) -> ChunkedArray<T>
|
109
109
|
where
|
@@ -136,7 +136,7 @@ fn iterator_to_bool(
|
|
136
136
|
it: impl Iterator<Item = Option<bool>>,
|
137
137
|
init_null_count: usize,
|
138
138
|
first_value: Option<bool>,
|
139
|
-
name:
|
139
|
+
name: PlSmallStr,
|
140
140
|
capacity: usize,
|
141
141
|
) -> ChunkedArray<BooleanType> {
|
142
142
|
// safety: we know the iterators len
|
@@ -166,7 +166,7 @@ fn iterator_to_object(
|
|
166
166
|
it: impl Iterator<Item = Option<ObjectValue>>,
|
167
167
|
init_null_count: usize,
|
168
168
|
first_value: Option<ObjectValue>,
|
169
|
-
name:
|
169
|
+
name: PlSmallStr,
|
170
170
|
capacity: usize,
|
171
171
|
) -> ObjectChunked<ObjectValue> {
|
172
172
|
// safety: we know the iterators len
|
@@ -196,7 +196,7 @@ fn iterator_to_utf8(
|
|
196
196
|
it: impl Iterator<Item = Option<String>>,
|
197
197
|
init_null_count: usize,
|
198
198
|
first_value: Option<&str>,
|
199
|
-
name:
|
199
|
+
name: PlSmallStr,
|
200
200
|
capacity: usize,
|
201
201
|
) -> StringChunked {
|
202
202
|
let first_value = first_value.map(|v| v.to_string());
|
@@ -229,7 +229,7 @@ fn iterator_to_list(
|
|
229
229
|
it: impl Iterator<Item = Option<Series>>,
|
230
230
|
init_null_count: usize,
|
231
231
|
first_value: Option<&Series>,
|
232
|
-
name:
|
232
|
+
name: PlSmallStr,
|
233
233
|
capacity: usize,
|
234
234
|
) -> RbResult<ListChunked> {
|
235
235
|
let mut builder =
|
@@ -246,7 +246,7 @@ fn iterator_to_list(
|
|
246
246
|
Some(s) => {
|
247
247
|
if s.len() == 0 && s.dtype() != dt {
|
248
248
|
builder
|
249
|
-
.append_series(&Series::full_null(
|
249
|
+
.append_series(&Series::full_null(PlSmallStr::EMPTY, 0, dt))
|
250
250
|
.unwrap()
|
251
251
|
} else {
|
252
252
|
builder.append_series(&s).map_err(RbPolarsErr::from)?
|