polars-df 0.8.0 → 0.10.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -1
  3. data/Cargo.lock +159 -66
  4. data/Cargo.toml +0 -3
  5. data/LICENSE.txt +1 -1
  6. data/README.md +3 -2
  7. data/ext/polars/Cargo.toml +18 -8
  8. data/ext/polars/src/batched_csv.rs +7 -5
  9. data/ext/polars/src/conversion/anyvalue.rs +186 -0
  10. data/ext/polars/src/conversion/chunked_array.rs +140 -0
  11. data/ext/polars/src/{conversion.rs → conversion/mod.rs} +273 -342
  12. data/ext/polars/src/dataframe.rs +108 -66
  13. data/ext/polars/src/expr/array.rs +78 -0
  14. data/ext/polars/src/expr/datetime.rs +29 -58
  15. data/ext/polars/src/expr/general.rs +83 -36
  16. data/ext/polars/src/expr/list.rs +58 -6
  17. data/ext/polars/src/expr/meta.rs +48 -0
  18. data/ext/polars/src/expr/rolling.rs +1 -0
  19. data/ext/polars/src/expr/string.rs +62 -11
  20. data/ext/polars/src/expr/struct.rs +8 -4
  21. data/ext/polars/src/file.rs +158 -11
  22. data/ext/polars/src/functions/aggregation.rs +6 -0
  23. data/ext/polars/src/functions/lazy.rs +120 -50
  24. data/ext/polars/src/functions/meta.rs +45 -1
  25. data/ext/polars/src/functions/string_cache.rs +14 -0
  26. data/ext/polars/src/functions/whenthen.rs +47 -17
  27. data/ext/polars/src/{lazyframe.rs → lazyframe/mod.rs} +195 -40
  28. data/ext/polars/src/lib.rs +246 -179
  29. data/ext/polars/src/map/dataframe.rs +17 -9
  30. data/ext/polars/src/series/aggregation.rs +20 -0
  31. data/ext/polars/src/series/mod.rs +35 -4
  32. data/lib/polars/array_expr.rb +453 -0
  33. data/lib/polars/array_name_space.rb +346 -0
  34. data/lib/polars/batched_csv_reader.rb +4 -2
  35. data/lib/polars/cat_expr.rb +24 -0
  36. data/lib/polars/cat_name_space.rb +75 -0
  37. data/lib/polars/config.rb +2 -2
  38. data/lib/polars/data_frame.rb +306 -96
  39. data/lib/polars/data_types.rb +191 -28
  40. data/lib/polars/date_time_expr.rb +41 -18
  41. data/lib/polars/date_time_name_space.rb +9 -3
  42. data/lib/polars/exceptions.rb +12 -1
  43. data/lib/polars/expr.rb +898 -215
  44. data/lib/polars/functions/aggregation/horizontal.rb +246 -0
  45. data/lib/polars/functions/aggregation/vertical.rb +282 -0
  46. data/lib/polars/functions/as_datatype.rb +248 -0
  47. data/lib/polars/functions/col.rb +47 -0
  48. data/lib/polars/functions/eager.rb +182 -0
  49. data/lib/polars/functions/lazy.rb +1280 -0
  50. data/lib/polars/functions/len.rb +49 -0
  51. data/lib/polars/functions/lit.rb +35 -0
  52. data/lib/polars/functions/random.rb +16 -0
  53. data/lib/polars/functions/range/date_range.rb +103 -0
  54. data/lib/polars/functions/range/int_range.rb +51 -0
  55. data/lib/polars/functions/repeat.rb +144 -0
  56. data/lib/polars/functions/whenthen.rb +96 -0
  57. data/lib/polars/functions.rb +29 -416
  58. data/lib/polars/group_by.rb +2 -2
  59. data/lib/polars/io.rb +36 -31
  60. data/lib/polars/lazy_frame.rb +405 -88
  61. data/lib/polars/list_expr.rb +158 -8
  62. data/lib/polars/list_name_space.rb +102 -0
  63. data/lib/polars/meta_expr.rb +175 -7
  64. data/lib/polars/series.rb +282 -41
  65. data/lib/polars/string_cache.rb +75 -0
  66. data/lib/polars/string_expr.rb +413 -96
  67. data/lib/polars/string_name_space.rb +4 -4
  68. data/lib/polars/testing.rb +507 -0
  69. data/lib/polars/utils.rb +106 -8
  70. data/lib/polars/version.rb +1 -1
  71. data/lib/polars/whenthen.rb +83 -0
  72. data/lib/polars.rb +16 -4
  73. metadata +37 -8
  74. data/lib/polars/lazy_functions.rb +0 -1181
  75. data/lib/polars/when.rb +0 -16
  76. data/lib/polars/when_then.rb +0 -19
@@ -0,0 +1,83 @@
1
+ module Polars
2
+ # @private
3
+ class When
4
+ attr_accessor :_when
5
+
6
+ def initialize(rbwhen)
7
+ self._when = rbwhen
8
+ end
9
+
10
+ def then(statement)
11
+ statement_rbexpr = Utils.parse_as_expression(statement)
12
+ Then.new(_when.then(statement_rbexpr))
13
+ end
14
+ end
15
+
16
+ # @private
17
+ class Then < Expr
18
+ attr_accessor :_then
19
+
20
+ def initialize(rbthen)
21
+ self._then = rbthen
22
+ end
23
+
24
+ def self._from_rbexpr(rbexpr)
25
+ Utils.wrap_expr(rbexpr)
26
+ end
27
+
28
+ def _rbexpr
29
+ _then.otherwise(Polars.lit(nil)._rbexpr)
30
+ end
31
+
32
+ def when(*predicates, **constraints)
33
+ condition_rbexpr = Utils.parse_when_inputs(*predicates, **constraints)
34
+ ChainedWhen.new(_then.when(condition_rbexpr))
35
+ end
36
+
37
+ def otherwise(statement)
38
+ statement_rbexpr = Utils.parse_as_expression(statement)
39
+ Utils.wrap_expr(_then.otherwise(statement_rbexpr))
40
+ end
41
+ end
42
+
43
+ # @private
44
+ class ChainedWhen
45
+ attr_accessor :_chained_when
46
+
47
+ def initialize(chained_when)
48
+ self._chained_when = chained_when
49
+ end
50
+
51
+ def then(statement)
52
+ statement_rbexpr = Utils.parse_as_expression(statement)
53
+ ChainedThen.new(_chained_when.then(statement_rbexpr))
54
+ end
55
+ end
56
+
57
+ # @private
58
+ class ChainedThen < Expr
59
+ attr_accessor :_chained_then
60
+
61
+ def initialize(chained_then)
62
+ self._chained_then = chained_then
63
+ end
64
+
65
+ def self._from_rbexpr(rbexpr)
66
+ Utils.wrap_expr(rbexpr)
67
+ end
68
+
69
+ def _rbexpr
70
+ _chained_then.otherwise(Polars.lit(nil)._rbexpr)
71
+ end
72
+
73
+ def when(*predicates, **constraints)
74
+ condition_rbexpr = Utils.parse_when_inputs(*predicates, **constraints)
75
+ ChainedWhen.new(_chained_then.when(condition_rbexpr))
76
+ end
77
+
78
+ def otherwise(statement)
79
+ statement_rbexpr = Utils.parse_as_expression(statement)
80
+ Utils.wrap_expr(_chained_then.otherwise(statement_rbexpr))
81
+ end
82
+ end
83
+ end
data/lib/polars.rb CHANGED
@@ -30,10 +30,22 @@ require_relative "polars/dynamic_group_by"
30
30
  require_relative "polars/exceptions"
31
31
  require_relative "polars/expr"
32
32
  require_relative "polars/functions"
33
+ require_relative "polars/functions/as_datatype"
34
+ require_relative "polars/functions/col"
35
+ require_relative "polars/functions/eager"
36
+ require_relative "polars/functions/lazy"
37
+ require_relative "polars/functions/len"
38
+ require_relative "polars/functions/lit"
39
+ require_relative "polars/functions/random"
40
+ require_relative "polars/functions/repeat"
41
+ require_relative "polars/functions/whenthen"
42
+ require_relative "polars/functions/aggregation/horizontal"
43
+ require_relative "polars/functions/aggregation/vertical"
44
+ require_relative "polars/functions/range/date_range"
45
+ require_relative "polars/functions/range/int_range"
33
46
  require_relative "polars/group_by"
34
47
  require_relative "polars/io"
35
48
  require_relative "polars/lazy_frame"
36
- require_relative "polars/lazy_functions"
37
49
  require_relative "polars/lazy_group_by"
38
50
  require_relative "polars/list_expr"
39
51
  require_relative "polars/list_name_space"
@@ -43,18 +55,18 @@ require_relative "polars/rolling_group_by"
43
55
  require_relative "polars/series"
44
56
  require_relative "polars/slice"
45
57
  require_relative "polars/sql_context"
58
+ require_relative "polars/string_cache"
46
59
  require_relative "polars/string_expr"
47
60
  require_relative "polars/string_name_space"
48
61
  require_relative "polars/struct_expr"
49
62
  require_relative "polars/struct_name_space"
63
+ require_relative "polars/testing"
50
64
  require_relative "polars/utils"
51
65
  require_relative "polars/version"
52
- require_relative "polars/when"
53
- require_relative "polars/when_then"
66
+ require_relative "polars/whenthen"
54
67
 
55
68
  module Polars
56
69
  extend Convert
57
70
  extend Functions
58
71
  extend IO
59
- extend LazyFunctions
60
72
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polars-df
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-10 00:00:00.000000000 Z
11
+ date: 2024-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bigdecimal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rb_sys
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -40,7 +54,9 @@ files:
40
54
  - ext/polars/Cargo.toml
41
55
  - ext/polars/extconf.rb
42
56
  - ext/polars/src/batched_csv.rs
43
- - ext/polars/src/conversion.rs
57
+ - ext/polars/src/conversion/anyvalue.rs
58
+ - ext/polars/src/conversion/chunked_array.rs
59
+ - ext/polars/src/conversion/mod.rs
44
60
  - ext/polars/src/dataframe.rs
45
61
  - ext/polars/src/error.rs
46
62
  - ext/polars/src/expr/array.rs
@@ -67,7 +83,7 @@ files:
67
83
  - ext/polars/src/functions/range.rs
68
84
  - ext/polars/src/functions/string_cache.rs
69
85
  - ext/polars/src/functions/whenthen.rs
70
- - ext/polars/src/lazyframe.rs
86
+ - ext/polars/src/lazyframe/mod.rs
71
87
  - ext/polars/src/lazygroupby.rs
72
88
  - ext/polars/src/lib.rs
73
89
  - ext/polars/src/map/dataframe.rs
@@ -107,10 +123,22 @@ files:
107
123
  - lib/polars/expr.rb
108
124
  - lib/polars/expr_dispatch.rb
109
125
  - lib/polars/functions.rb
126
+ - lib/polars/functions/aggregation/horizontal.rb
127
+ - lib/polars/functions/aggregation/vertical.rb
128
+ - lib/polars/functions/as_datatype.rb
129
+ - lib/polars/functions/col.rb
130
+ - lib/polars/functions/eager.rb
131
+ - lib/polars/functions/lazy.rb
132
+ - lib/polars/functions/len.rb
133
+ - lib/polars/functions/lit.rb
134
+ - lib/polars/functions/random.rb
135
+ - lib/polars/functions/range/date_range.rb
136
+ - lib/polars/functions/range/int_range.rb
137
+ - lib/polars/functions/repeat.rb
138
+ - lib/polars/functions/whenthen.rb
110
139
  - lib/polars/group_by.rb
111
140
  - lib/polars/io.rb
112
141
  - lib/polars/lazy_frame.rb
113
- - lib/polars/lazy_functions.rb
114
142
  - lib/polars/lazy_group_by.rb
115
143
  - lib/polars/list_expr.rb
116
144
  - lib/polars/list_name_space.rb
@@ -121,14 +149,15 @@ files:
121
149
  - lib/polars/series.rb
122
150
  - lib/polars/slice.rb
123
151
  - lib/polars/sql_context.rb
152
+ - lib/polars/string_cache.rb
124
153
  - lib/polars/string_expr.rb
125
154
  - lib/polars/string_name_space.rb
126
155
  - lib/polars/struct_expr.rb
127
156
  - lib/polars/struct_name_space.rb
157
+ - lib/polars/testing.rb
128
158
  - lib/polars/utils.rb
129
159
  - lib/polars/version.rb
130
- - lib/polars/when.rb
131
- - lib/polars/when_then.rb
160
+ - lib/polars/whenthen.rb
132
161
  homepage: https://github.com/ankane/polars-ruby
133
162
  licenses:
134
163
  - MIT
@@ -148,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
177
  - !ruby/object:Gem::Version
149
178
  version: '0'
150
179
  requirements: []
151
- rubygems_version: 3.5.3
180
+ rubygems_version: 3.5.9
152
181
  signing_key:
153
182
  specification_version: 4
154
183
  summary: Blazingly fast DataFrames for Ruby