polars-df 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/Cargo.lock +353 -237
  4. data/Cargo.toml +0 -3
  5. data/LICENSE.txt +1 -1
  6. data/README.md +2 -2
  7. data/ext/polars/Cargo.toml +17 -6
  8. data/ext/polars/src/batched_csv.rs +6 -7
  9. data/ext/polars/src/conversion/anyvalue.rs +185 -0
  10. data/ext/polars/src/conversion/chunked_array.rs +140 -0
  11. data/ext/polars/src/{conversion.rs → conversion/mod.rs} +268 -347
  12. data/ext/polars/src/dataframe.rs +96 -116
  13. data/ext/polars/src/expr/array.rs +74 -0
  14. data/ext/polars/src/expr/categorical.rs +8 -1
  15. data/ext/polars/src/expr/datetime.rs +22 -56
  16. data/ext/polars/src/expr/general.rs +124 -37
  17. data/ext/polars/src/expr/list.rs +52 -4
  18. data/ext/polars/src/expr/meta.rs +48 -0
  19. data/ext/polars/src/expr/rolling.rs +16 -10
  20. data/ext/polars/src/expr/string.rs +68 -17
  21. data/ext/polars/src/expr/struct.rs +8 -4
  22. data/ext/polars/src/functions/aggregation.rs +6 -0
  23. data/ext/polars/src/functions/lazy.rs +103 -48
  24. data/ext/polars/src/functions/meta.rs +45 -1
  25. data/ext/polars/src/functions/range.rs +5 -10
  26. data/ext/polars/src/functions/string_cache.rs +14 -0
  27. data/ext/polars/src/{lazyframe.rs → lazyframe/mod.rs} +166 -41
  28. data/ext/polars/src/lib.rs +245 -187
  29. data/ext/polars/src/map/dataframe.rs +1 -1
  30. data/ext/polars/src/map/mod.rs +2 -2
  31. data/ext/polars/src/map/series.rs +6 -6
  32. data/ext/polars/src/object.rs +0 -30
  33. data/ext/polars/src/on_startup.rs +32 -0
  34. data/ext/polars/src/series/aggregation.rs +23 -0
  35. data/ext/polars/src/series/construction.rs +1 -1
  36. data/ext/polars/src/series/export.rs +2 -2
  37. data/ext/polars/src/{series.rs → series/mod.rs} +45 -21
  38. data/ext/polars/src/series/{set_at_idx.rs → scatter.rs} +18 -18
  39. data/ext/polars/src/utils.rs +1 -1
  40. data/lib/polars/array_expr.rb +449 -0
  41. data/lib/polars/array_name_space.rb +346 -0
  42. data/lib/polars/cat_expr.rb +24 -0
  43. data/lib/polars/cat_name_space.rb +75 -0
  44. data/lib/polars/config.rb +2 -2
  45. data/lib/polars/data_frame.rb +248 -108
  46. data/lib/polars/data_types.rb +195 -29
  47. data/lib/polars/date_time_expr.rb +41 -24
  48. data/lib/polars/date_time_name_space.rb +12 -12
  49. data/lib/polars/exceptions.rb +12 -1
  50. data/lib/polars/expr.rb +1080 -195
  51. data/lib/polars/functions/aggregation/horizontal.rb +246 -0
  52. data/lib/polars/functions/aggregation/vertical.rb +282 -0
  53. data/lib/polars/functions/as_datatype.rb +248 -0
  54. data/lib/polars/functions/col.rb +47 -0
  55. data/lib/polars/functions/eager.rb +182 -0
  56. data/lib/polars/functions/lazy.rb +1280 -0
  57. data/lib/polars/functions/len.rb +49 -0
  58. data/lib/polars/functions/lit.rb +35 -0
  59. data/lib/polars/functions/random.rb +16 -0
  60. data/lib/polars/functions/range/date_range.rb +103 -0
  61. data/lib/polars/functions/range/int_range.rb +51 -0
  62. data/lib/polars/functions/repeat.rb +144 -0
  63. data/lib/polars/functions/whenthen.rb +27 -0
  64. data/lib/polars/functions.rb +29 -416
  65. data/lib/polars/group_by.rb +3 -3
  66. data/lib/polars/io.rb +21 -28
  67. data/lib/polars/lazy_frame.rb +390 -76
  68. data/lib/polars/list_expr.rb +152 -6
  69. data/lib/polars/list_name_space.rb +102 -0
  70. data/lib/polars/meta_expr.rb +175 -7
  71. data/lib/polars/series.rb +557 -59
  72. data/lib/polars/sql_context.rb +1 -1
  73. data/lib/polars/string_cache.rb +75 -0
  74. data/lib/polars/string_expr.rb +412 -96
  75. data/lib/polars/string_name_space.rb +4 -4
  76. data/lib/polars/struct_expr.rb +1 -1
  77. data/lib/polars/struct_name_space.rb +1 -1
  78. data/lib/polars/testing.rb +507 -0
  79. data/lib/polars/utils.rb +64 -20
  80. data/lib/polars/version.rb +1 -1
  81. data/lib/polars.rb +15 -2
  82. metadata +40 -9
  83. data/lib/polars/lazy_functions.rb +0 -1197
@@ -157,7 +157,7 @@ module Polars
157
157
  # ctx.unregister(["test1", "test3"]).tables
158
158
  # # => ["test2"]
159
159
  def unregister(names)
160
- if names.is_a?(String)
160
+ if names.is_a?(::String)
161
161
  names = [names]
162
162
  end
163
163
  names.each do |nm|
@@ -0,0 +1,75 @@
1
+ module Polars
2
+ # Context manager for enabling and disabling the global string cache.
3
+ class StringCache
4
+ def initialize(&block)
5
+ RbStringCacheHolder.hold(&block)
6
+ end
7
+ end
8
+
9
+ module Functions
10
+ # Enable the global string cache.
11
+ #
12
+ # `Categorical` columns created under the same global string cache have
13
+ # the same underlying physical value when string values are equal. This allows the
14
+ # columns to be concatenated or used in a join operation, for example.
15
+ #
16
+ # @return [nil]
17
+ #
18
+ # @example Construct two Series using the same global string cache.
19
+ # Polars.enable_string_cache
20
+ # s1 = Polars::Series.new("color", ["red", "green", "red"], dtype: Polars::Categorical)
21
+ # s2 = Polars::Series.new("color", ["blue", "red", "green"], dtype: Polars::Categorical)
22
+ # Polars.disable_string_cache
23
+ #
24
+ # @example As both Series are constructed under the same global string cache, they can be concatenated.
25
+ # Polars.concat([s1, s2])
26
+ # # =>
27
+ # # shape: (6,)
28
+ # # Series: 'color' [cat]
29
+ # # [
30
+ # # "red"
31
+ # # "green"
32
+ # # "red"
33
+ # # "blue"
34
+ # # "red"
35
+ # # "green"
36
+ # # ]
37
+ def enable_string_cache
38
+ Plr.enable_string_cache
39
+ end
40
+
41
+ # Disable and clear the global string cache.
42
+ #
43
+ # @return [nil]
44
+ #
45
+ # @example Construct two Series using the same global string cache.
46
+ # Polars.enable_string_cache
47
+ # s1 = Polars::Series.new("color", ["red", "green", "red"], dtype: Polars::Categorical)
48
+ # s2 = Polars::Series.new("color", ["blue", "red", "green"], dtype: Polars::Categorical)
49
+ # Polars.disable_string_cache
50
+ #
51
+ # @example As both Series are constructed under the same global string cache, they can be concatenated.
52
+ # Polars.concat([s1, s2])
53
+ # # =>
54
+ # # shape: (6,)
55
+ # # Series: 'color' [cat]
56
+ # # [
57
+ # # "red"
58
+ # # "green"
59
+ # # "red"
60
+ # # "blue"
61
+ # # "red"
62
+ # # "green"
63
+ # # ]
64
+ def disable_string_cache
65
+ Plr.disable_string_cache
66
+ end
67
+
68
+ # Check whether the global string cache is enabled.
69
+ #
70
+ # @return [Boolean]
71
+ def using_string_cache
72
+ Plr.using_string_cache
73
+ end
74
+ end
75
+ end