polars-df 0.4.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/Cargo.lock +447 -410
  4. data/Cargo.toml +0 -1
  5. data/README.md +6 -5
  6. data/ext/polars/Cargo.toml +10 -5
  7. data/ext/polars/src/apply/dataframe.rs +2 -2
  8. data/ext/polars/src/{lazy/apply.rs → apply/lazy.rs} +1 -2
  9. data/ext/polars/src/apply/mod.rs +8 -3
  10. data/ext/polars/src/batched_csv.rs +7 -5
  11. data/ext/polars/src/conversion.rs +269 -59
  12. data/ext/polars/src/dataframe.rs +38 -40
  13. data/ext/polars/src/error.rs +6 -2
  14. data/ext/polars/src/expr/array.rs +15 -0
  15. data/ext/polars/src/expr/binary.rs +69 -0
  16. data/ext/polars/src/expr/categorical.rs +10 -0
  17. data/ext/polars/src/expr/datetime.rs +223 -0
  18. data/ext/polars/src/expr/general.rs +963 -0
  19. data/ext/polars/src/expr/list.rs +151 -0
  20. data/ext/polars/src/{lazy → expr}/meta.rs +16 -6
  21. data/ext/polars/src/expr/string.rs +314 -0
  22. data/ext/polars/src/expr/struct.rs +15 -0
  23. data/ext/polars/src/expr.rs +34 -0
  24. data/ext/polars/src/functions/eager.rs +93 -0
  25. data/ext/polars/src/functions/io.rs +34 -0
  26. data/ext/polars/src/functions/lazy.rs +249 -0
  27. data/ext/polars/src/functions/meta.rs +8 -0
  28. data/ext/polars/src/functions/mod.rs +5 -0
  29. data/ext/polars/src/functions/whenthen.rs +43 -0
  30. data/ext/polars/src/{lazy/dataframe.rs → lazyframe.rs} +26 -35
  31. data/ext/polars/src/lazygroupby.rs +29 -0
  32. data/ext/polars/src/lib.rs +223 -316
  33. data/ext/polars/src/object.rs +1 -1
  34. data/ext/polars/src/rb_modules.rs +12 -0
  35. data/ext/polars/src/series/aggregation.rs +83 -0
  36. data/ext/polars/src/series/arithmetic.rs +88 -0
  37. data/ext/polars/src/series/comparison.rs +251 -0
  38. data/ext/polars/src/series/construction.rs +190 -0
  39. data/ext/polars/src/series.rs +151 -551
  40. data/lib/polars/array_expr.rb +84 -0
  41. data/lib/polars/array_name_space.rb +77 -0
  42. data/lib/polars/batched_csv_reader.rb +1 -1
  43. data/lib/polars/convert.rb +2 -2
  44. data/lib/polars/data_frame.rb +289 -96
  45. data/lib/polars/data_types.rb +169 -33
  46. data/lib/polars/date_time_expr.rb +142 -2
  47. data/lib/polars/date_time_name_space.rb +17 -3
  48. data/lib/polars/expr.rb +145 -78
  49. data/lib/polars/functions.rb +0 -1
  50. data/lib/polars/group_by.rb +1 -22
  51. data/lib/polars/lazy_frame.rb +84 -31
  52. data/lib/polars/lazy_functions.rb +71 -32
  53. data/lib/polars/list_expr.rb +94 -45
  54. data/lib/polars/list_name_space.rb +13 -13
  55. data/lib/polars/rolling_group_by.rb +4 -2
  56. data/lib/polars/series.rb +249 -87
  57. data/lib/polars/string_expr.rb +277 -45
  58. data/lib/polars/string_name_space.rb +137 -22
  59. data/lib/polars/struct_name_space.rb +32 -0
  60. data/lib/polars/utils.rb +138 -54
  61. data/lib/polars/version.rb +1 -1
  62. data/lib/polars.rb +5 -2
  63. metadata +29 -11
  64. data/ext/polars/src/lazy/dsl.rs +0 -1775
  65. data/ext/polars/src/lazy/mod.rs +0 -5
  66. data/ext/polars/src/lazy/utils.rs +0 -13
  67. data/ext/polars/src/list_construction.rs +0 -100
  68. /data/ext/polars/src/{numo.rs → series/export.rs} +0 -0
  69. /data/ext/polars/src/{set.rs → series/set_at_idx.rs} +0 -0
@@ -1,5 +0,0 @@
1
- pub mod apply;
2
- pub mod dataframe;
3
- pub mod dsl;
4
- pub mod meta;
5
- pub mod utils;
@@ -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