polars-df 0.4.0 → 0.5.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 +12 -0
- data/Cargo.lock +272 -191
- data/Cargo.toml +0 -1
- data/README.md +2 -2
- data/ext/polars/Cargo.toml +8 -4
- data/ext/polars/src/apply/dataframe.rs +2 -2
- data/ext/polars/src/{lazy/apply.rs → apply/lazy.rs} +1 -2
- data/ext/polars/src/apply/mod.rs +1 -0
- data/ext/polars/src/batched_csv.rs +7 -5
- data/ext/polars/src/conversion.rs +106 -4
- data/ext/polars/src/dataframe.rs +19 -17
- data/ext/polars/src/error.rs +0 -4
- data/ext/polars/src/expr/binary.rs +69 -0
- data/ext/polars/src/expr/categorical.rs +10 -0
- data/ext/polars/src/expr/datetime.rs +223 -0
- data/ext/polars/src/expr/general.rs +933 -0
- data/ext/polars/src/expr/list.rs +146 -0
- data/ext/polars/src/{lazy → expr}/meta.rs +16 -6
- data/ext/polars/src/expr/string.rs +313 -0
- data/ext/polars/src/expr/struct.rs +15 -0
- data/ext/polars/src/expr.rs +33 -0
- data/ext/polars/src/functions/eager.rs +93 -0
- data/ext/polars/src/functions/io.rs +34 -0
- data/ext/polars/src/functions/lazy.rs +209 -0
- data/ext/polars/src/functions/meta.rs +8 -0
- data/ext/polars/src/functions/mod.rs +5 -0
- data/ext/polars/src/functions/whenthen.rs +43 -0
- data/ext/polars/src/{lazy/dataframe.rs → lazyframe.rs} +12 -33
- data/ext/polars/src/lazygroupby.rs +29 -0
- data/ext/polars/src/lib.rs +205 -303
- data/ext/polars/src/rb_modules.rs +8 -0
- data/ext/polars/src/series/aggregation.rs +83 -0
- data/ext/polars/src/series/arithmetic.rs +88 -0
- data/ext/polars/src/series/comparison.rs +251 -0
- data/ext/polars/src/series/construction.rs +164 -0
- data/ext/polars/src/series.rs +99 -539
- data/lib/polars/convert.rb +2 -2
- data/lib/polars/data_frame.rb +201 -50
- data/lib/polars/data_types.rb +6 -4
- data/lib/polars/date_time_expr.rb +142 -2
- data/lib/polars/expr.rb +70 -10
- data/lib/polars/lazy_frame.rb +4 -3
- data/lib/polars/lazy_functions.rb +4 -1
- data/lib/polars/list_expr.rb +68 -19
- data/lib/polars/series.rb +181 -73
- data/lib/polars/string_expr.rb +149 -43
- data/lib/polars/string_name_space.rb +4 -4
- data/lib/polars/struct_name_space.rb +32 -0
- data/lib/polars/utils.rb +41 -7
- data/lib/polars/version.rb +1 -1
- data/lib/polars.rb +2 -2
- metadata +26 -11
- data/ext/polars/src/lazy/dsl.rs +0 -1775
- data/ext/polars/src/lazy/mod.rs +0 -5
- data/ext/polars/src/lazy/utils.rs +0 -13
- data/ext/polars/src/list_construction.rs +0 -100
- /data/ext/polars/src/{numo.rs → series/export.rs} +0 -0
- /data/ext/polars/src/{set.rs → series/set_at_idx.rs} +0 -0
data/ext/polars/src/lazy/mod.rs
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
use magnus::RArray;
|
2
|
-
use polars::lazy::dsl::Expr;
|
3
|
-
|
4
|
-
use crate::lazy::dsl::RbExpr;
|
5
|
-
use crate::RbResult;
|
6
|
-
|
7
|
-
pub fn rb_exprs_to_exprs(rb_exprs: RArray) -> RbResult<Vec<Expr>> {
|
8
|
-
let mut exprs = Vec::new();
|
9
|
-
for item in rb_exprs.each() {
|
10
|
-
exprs.push(item?.try_convert::<&RbExpr>()?.inner.clone());
|
11
|
-
}
|
12
|
-
Ok(exprs)
|
13
|
-
}
|
@@ -1,100 +0,0 @@
|
|
1
|
-
use magnus::Value;
|
2
|
-
use polars::prelude::*;
|
3
|
-
use polars_core::utils::CustomIterTools;
|
4
|
-
|
5
|
-
use crate::conversion::get_rbseq;
|
6
|
-
use crate::{RbPolarsErr, RbResult};
|
7
|
-
|
8
|
-
pub fn rb_seq_to_list(name: &str, seq: Value, dtype: &DataType) -> RbResult<Series> {
|
9
|
-
let (seq, len) = get_rbseq(seq)?;
|
10
|
-
|
11
|
-
let s = match dtype {
|
12
|
-
DataType::Int64 => {
|
13
|
-
let mut builder =
|
14
|
-
ListPrimitiveChunkedBuilder::<Int64Type>::new(name, len, len * 5, DataType::Int64);
|
15
|
-
for sub_seq in seq.each() {
|
16
|
-
let sub_seq = sub_seq?;
|
17
|
-
let (sub_seq, len) = get_rbseq(sub_seq)?;
|
18
|
-
|
19
|
-
// safety: we know the iterators len
|
20
|
-
let iter = unsafe {
|
21
|
-
sub_seq
|
22
|
-
.each()
|
23
|
-
.map(|v| {
|
24
|
-
let v = v.unwrap();
|
25
|
-
if v.is_nil() {
|
26
|
-
None
|
27
|
-
} else {
|
28
|
-
Some(v.try_convert::<i64>().unwrap())
|
29
|
-
}
|
30
|
-
})
|
31
|
-
.trust_my_length(len)
|
32
|
-
};
|
33
|
-
builder.append_iter(iter)
|
34
|
-
}
|
35
|
-
builder.finish().into_series()
|
36
|
-
}
|
37
|
-
DataType::Float64 => {
|
38
|
-
let mut builder = ListPrimitiveChunkedBuilder::<Float64Type>::new(
|
39
|
-
name,
|
40
|
-
len,
|
41
|
-
len * 5,
|
42
|
-
DataType::Float64,
|
43
|
-
);
|
44
|
-
for sub_seq in seq.each() {
|
45
|
-
let sub_seq = sub_seq?;
|
46
|
-
let (sub_seq, len) = get_rbseq(sub_seq)?;
|
47
|
-
// safety: we know the iterators len
|
48
|
-
let iter = unsafe {
|
49
|
-
sub_seq
|
50
|
-
.each()
|
51
|
-
.map(|v| {
|
52
|
-
let v = v.unwrap();
|
53
|
-
if v.is_nil() {
|
54
|
-
None
|
55
|
-
} else {
|
56
|
-
Some(v.try_convert::<f64>().unwrap())
|
57
|
-
}
|
58
|
-
})
|
59
|
-
.trust_my_length(len)
|
60
|
-
};
|
61
|
-
builder.append_iter(iter)
|
62
|
-
}
|
63
|
-
builder.finish().into_series()
|
64
|
-
}
|
65
|
-
DataType::Boolean => {
|
66
|
-
let mut builder = ListBooleanChunkedBuilder::new(name, len, len * 5);
|
67
|
-
for sub_seq in seq.each() {
|
68
|
-
let sub_seq = sub_seq?;
|
69
|
-
let (sub_seq, len) = get_rbseq(sub_seq)?;
|
70
|
-
// safety: we know the iterators len
|
71
|
-
let iter = unsafe {
|
72
|
-
sub_seq
|
73
|
-
.each()
|
74
|
-
.map(|v| {
|
75
|
-
let v = v.unwrap();
|
76
|
-
if v.is_nil() {
|
77
|
-
None
|
78
|
-
} else {
|
79
|
-
Some(v.try_convert::<bool>().unwrap())
|
80
|
-
}
|
81
|
-
})
|
82
|
-
.trust_my_length(len)
|
83
|
-
};
|
84
|
-
builder.append_iter(iter)
|
85
|
-
}
|
86
|
-
builder.finish().into_series()
|
87
|
-
}
|
88
|
-
DataType::Utf8 => {
|
89
|
-
return Err(RbPolarsErr::todo());
|
90
|
-
}
|
91
|
-
dt => {
|
92
|
-
return Err(RbPolarsErr::other(format!(
|
93
|
-
"cannot create list array from {:?}",
|
94
|
-
dt
|
95
|
-
)));
|
96
|
-
}
|
97
|
-
};
|
98
|
-
|
99
|
-
Ok(s)
|
100
|
-
}
|
File without changes
|
File without changes
|