polars-df 0.21.0 → 0.21.1

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/Cargo.lock +1 -1
  4. data/ext/polars/Cargo.toml +7 -1
  5. data/ext/polars/src/conversion/mod.rs +92 -4
  6. data/ext/polars/src/exceptions.rs +1 -0
  7. data/ext/polars/src/expr/array.rs +73 -4
  8. data/ext/polars/src/expr/binary.rs +26 -1
  9. data/ext/polars/src/expr/bitwise.rs +39 -0
  10. data/ext/polars/src/expr/categorical.rs +20 -0
  11. data/ext/polars/src/expr/datatype.rs +24 -1
  12. data/ext/polars/src/expr/datetime.rs +58 -0
  13. data/ext/polars/src/expr/general.rs +84 -5
  14. data/ext/polars/src/expr/list.rs +24 -0
  15. data/ext/polars/src/expr/meta.rs +11 -0
  16. data/ext/polars/src/expr/mod.rs +1 -0
  17. data/ext/polars/src/expr/name.rs +8 -0
  18. data/ext/polars/src/expr/rolling.rs +20 -0
  19. data/ext/polars/src/expr/string.rs +59 -0
  20. data/ext/polars/src/expr/struct.rs +9 -1
  21. data/ext/polars/src/functions/io.rs +19 -0
  22. data/ext/polars/src/functions/lazy.rs +4 -0
  23. data/ext/polars/src/lazyframe/general.rs +51 -0
  24. data/ext/polars/src/lib.rs +119 -10
  25. data/ext/polars/src/map/dataframe.rs +2 -2
  26. data/ext/polars/src/map/series.rs +1 -1
  27. data/ext/polars/src/series/aggregation.rs +44 -0
  28. data/ext/polars/src/series/general.rs +64 -4
  29. data/lib/polars/array_expr.rb +382 -3
  30. data/lib/polars/array_name_space.rb +281 -0
  31. data/lib/polars/binary_expr.rb +67 -0
  32. data/lib/polars/binary_name_space.rb +43 -0
  33. data/lib/polars/cat_expr.rb +224 -0
  34. data/lib/polars/cat_name_space.rb +138 -0
  35. data/lib/polars/config.rb +2 -2
  36. data/lib/polars/convert.rb +6 -6
  37. data/lib/polars/data_frame.rb +684 -19
  38. data/lib/polars/data_type_expr.rb +52 -0
  39. data/lib/polars/data_types.rb +14 -2
  40. data/lib/polars/date_time_expr.rb +251 -0
  41. data/lib/polars/date_time_name_space.rb +299 -0
  42. data/lib/polars/expr.rb +1213 -180
  43. data/lib/polars/functions/datatype.rb +21 -0
  44. data/lib/polars/functions/lazy.rb +13 -0
  45. data/lib/polars/io/csv.rb +1 -1
  46. data/lib/polars/io/json.rb +4 -4
  47. data/lib/polars/io/ndjson.rb +4 -4
  48. data/lib/polars/io/parquet.rb +27 -5
  49. data/lib/polars/lazy_frame.rb +936 -20
  50. data/lib/polars/list_expr.rb +196 -4
  51. data/lib/polars/list_name_space.rb +201 -4
  52. data/lib/polars/meta_expr.rb +64 -0
  53. data/lib/polars/name_expr.rb +36 -0
  54. data/lib/polars/schema.rb +79 -3
  55. data/lib/polars/selector.rb +72 -0
  56. data/lib/polars/selectors.rb +3 -3
  57. data/lib/polars/series.rb +1051 -54
  58. data/lib/polars/string_expr.rb +411 -6
  59. data/lib/polars/string_name_space.rb +722 -49
  60. data/lib/polars/struct_expr.rb +103 -0
  61. data/lib/polars/struct_name_space.rb +19 -1
  62. data/lib/polars/utils/various.rb +18 -1
  63. data/lib/polars/utils.rb +5 -1
  64. data/lib/polars/version.rb +1 -1
  65. data/lib/polars.rb +2 -0
  66. metadata +4 -1
@@ -44,5 +44,143 @@ module Polars
44
44
  def to_local
45
45
  Utils.wrap_s(_s.cat_to_local)
46
46
  end
47
+
48
+ # Indicate whether the Series uses lexical ordering.
49
+ #
50
+ # @note
51
+ # This functionality is considered **unstable**. It may be changed
52
+ # at any point without it being considered a breaking change.
53
+ #
54
+ # @return [Boolean]
55
+ #
56
+ # @example
57
+ # s = Polars::Series.new(["b", "a", "b"]).cast(Polars::Categorical)
58
+ # s.cat.uses_lexical_ordering
59
+ # # => true
60
+ def uses_lexical_ordering
61
+ _s.cat_uses_lexical_ordering
62
+ end
63
+
64
+ # Return the byte-length of the string representation of each value.
65
+ #
66
+ # @return [Series]
67
+ #
68
+ # @example
69
+ # s = Polars::Series.new(["Café", "345", "東京", nil], dtype: Polars::Categorical)
70
+ # s.cat.len_bytes
71
+ # # =>
72
+ # # shape: (4,)
73
+ # # Series: '' [u32]
74
+ # # [
75
+ # # 5
76
+ # # 3
77
+ # # 6
78
+ # # null
79
+ # # ]
80
+ def len_bytes
81
+ super
82
+ end
83
+
84
+ # Return the number of characters of the string representation of each value.
85
+ #
86
+ # @return [Series]
87
+ #
88
+ # @example
89
+ # s = Polars::Series.new(["Café", "345", "東京", nil], dtype: Polars::Categorical)
90
+ # s.cat.len_chars
91
+ # # =>
92
+ # # shape: (4,)
93
+ # # Series: '' [u32]
94
+ # # [
95
+ # # 4
96
+ # # 3
97
+ # # 2
98
+ # # null
99
+ # # ]
100
+ def len_chars
101
+ super
102
+ end
103
+
104
+ # Check if string representations of values start with a substring.
105
+ #
106
+ # @param prefix [String]
107
+ # Prefix substring.
108
+ #
109
+ # @return [Series]
110
+ #
111
+ # @example
112
+ # s = Polars::Series.new("fruits", ["apple", "mango", nil], dtype: Polars::Categorical)
113
+ # s.cat.starts_with("app")
114
+ # # =>
115
+ # # shape: (3,)
116
+ # # Series: 'fruits' [bool]
117
+ # # [
118
+ # # true
119
+ # # false
120
+ # # null
121
+ # # ]
122
+ def starts_with(prefix)
123
+ super
124
+ end
125
+
126
+ # Check if string representations of values end with a substring.
127
+ #
128
+ # @param suffix [String]
129
+ # Suffix substring.
130
+ #
131
+ # @return [Series]
132
+ #
133
+ # @example
134
+ # s = Polars::Series.new("fruits", ["apple", "mango", nil], dtype: Polars::Categorical)
135
+ # s.cat.ends_with("go")
136
+ # # =>
137
+ # # shape: (3,)
138
+ # # Series: 'fruits' [bool]
139
+ # # [
140
+ # # false
141
+ # # true
142
+ # # null
143
+ # # ]
144
+ def ends_with(suffix)
145
+ super
146
+ end
147
+
148
+ # Extract a substring from the string representation of each string value.
149
+ #
150
+ # @param offset [Integer]
151
+ # Start index. Negative indexing is supported.
152
+ # @param length [Integer]
153
+ # Length of the slice. If set to `nil` (default), the slice is taken to the
154
+ # end of the string.
155
+ #
156
+ # @return [Series]
157
+ #
158
+ # @example
159
+ # s = Polars::Series.new(["pear", nil, "papaya", "dragonfruit"], dtype: Polars::Categorical)
160
+ # s.cat.slice(-3)
161
+ # # =>
162
+ # # shape: (4,)
163
+ # # Series: '' [str]
164
+ # # [
165
+ # # "ear"
166
+ # # null
167
+ # # "aya"
168
+ # # "uit"
169
+ # # ]
170
+ #
171
+ # @example Using the optional `length` parameter
172
+ # s.cat.slice(4, 3)
173
+ # # =>
174
+ # # shape: (4,)
175
+ # # Series: '' [str]
176
+ # # [
177
+ # # ""
178
+ # # null
179
+ # # "ya"
180
+ # # "onf"
181
+ # # ]
182
+ def slice(offset, length = nil)
183
+ super
184
+ end
47
185
  end
48
186
  end
data/lib/polars/config.rb CHANGED
@@ -80,11 +80,11 @@ module Polars
80
80
  options
81
81
  end
82
82
 
83
- # Show the current state of all Config variables as a dict.
83
+ # Show the current state of all Config variables as a hash.
84
84
  #
85
85
  # @param if_set [Boolean]
86
86
  # by default this will show the state of all `Config` environment variables.
87
- # change this to `true` to restrict the returned dictionary to include only
87
+ # change this to `true` to restrict the returned hash to include only
88
88
  # those that have been set to a specific value.
89
89
  # @param env_only [Boolean]
90
90
  # include only Config environment variables in the output; some options (such
@@ -1,6 +1,6 @@
1
1
  module Polars
2
2
  module Convert
3
- # Construct a DataFrame from a dictionary of sequences.
3
+ # Construct a DataFrame from a hash of arrays.
4
4
  #
5
5
  # This operation clones data, unless you pass in a `Hash<String, Series>`.
6
6
  #
@@ -10,11 +10,11 @@ module Polars
10
10
  # @param schema [Object]
11
11
  # The DataFrame schema may be declared in several ways:
12
12
  #
13
- # * As a dict of {name:type} pairs; if type is None, it will be auto-inferred.
14
- # * As a list of column names; in this case types are automatically inferred.
15
- # * As a list of (name,type) pairs; this is equivalent to the dictionary form.
13
+ # * As a hash of \\\\{name:type} pairs; if type is nil, it will be auto-inferred.
14
+ # * As an array of column names; in this case types are automatically inferred.
15
+ # * As an array of [name,type] pairs; this is equivalent to the hash form.
16
16
  #
17
- # If you supply a list of column names that does not match the names in the
17
+ # If you supply an array of column names that does not match the names in the
18
18
  # underlying data, the names given here will overwrite them. The number
19
19
  # of names given in the schema should match the underlying data dimensions.
20
20
  # @param columns [Array]
@@ -45,7 +45,7 @@ module Polars
45
45
  )
46
46
  end
47
47
 
48
- # Construct a DataFrame from a sequence of dictionaries. This operation clones data.
48
+ # Construct a DataFrame from an array of hashes. This operation clones data.
49
49
  #
50
50
  # @param hashes [Array]
51
51
  # Array with hashes mapping column name to value.