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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/Cargo.lock +1 -1
- data/ext/polars/Cargo.toml +7 -1
- data/ext/polars/src/conversion/mod.rs +92 -4
- data/ext/polars/src/exceptions.rs +1 -0
- data/ext/polars/src/expr/array.rs +73 -4
- data/ext/polars/src/expr/binary.rs +26 -1
- data/ext/polars/src/expr/bitwise.rs +39 -0
- data/ext/polars/src/expr/categorical.rs +20 -0
- data/ext/polars/src/expr/datatype.rs +24 -1
- data/ext/polars/src/expr/datetime.rs +58 -0
- data/ext/polars/src/expr/general.rs +84 -5
- data/ext/polars/src/expr/list.rs +24 -0
- data/ext/polars/src/expr/meta.rs +11 -0
- data/ext/polars/src/expr/mod.rs +1 -0
- data/ext/polars/src/expr/name.rs +8 -0
- data/ext/polars/src/expr/rolling.rs +20 -0
- data/ext/polars/src/expr/string.rs +59 -0
- data/ext/polars/src/expr/struct.rs +9 -1
- data/ext/polars/src/functions/io.rs +19 -0
- data/ext/polars/src/functions/lazy.rs +4 -0
- data/ext/polars/src/lazyframe/general.rs +51 -0
- data/ext/polars/src/lib.rs +119 -10
- data/ext/polars/src/map/dataframe.rs +2 -2
- data/ext/polars/src/map/series.rs +1 -1
- data/ext/polars/src/series/aggregation.rs +44 -0
- data/ext/polars/src/series/general.rs +64 -4
- data/lib/polars/array_expr.rb +382 -3
- data/lib/polars/array_name_space.rb +281 -0
- data/lib/polars/binary_expr.rb +67 -0
- data/lib/polars/binary_name_space.rb +43 -0
- data/lib/polars/cat_expr.rb +224 -0
- data/lib/polars/cat_name_space.rb +138 -0
- data/lib/polars/config.rb +2 -2
- data/lib/polars/convert.rb +6 -6
- data/lib/polars/data_frame.rb +684 -19
- data/lib/polars/data_type_expr.rb +52 -0
- data/lib/polars/data_types.rb +14 -2
- data/lib/polars/date_time_expr.rb +251 -0
- data/lib/polars/date_time_name_space.rb +299 -0
- data/lib/polars/expr.rb +1213 -180
- data/lib/polars/functions/datatype.rb +21 -0
- data/lib/polars/functions/lazy.rb +13 -0
- data/lib/polars/io/csv.rb +1 -1
- data/lib/polars/io/json.rb +4 -4
- data/lib/polars/io/ndjson.rb +4 -4
- data/lib/polars/io/parquet.rb +27 -5
- data/lib/polars/lazy_frame.rb +936 -20
- data/lib/polars/list_expr.rb +196 -4
- data/lib/polars/list_name_space.rb +201 -4
- data/lib/polars/meta_expr.rb +64 -0
- data/lib/polars/name_expr.rb +36 -0
- data/lib/polars/schema.rb +79 -3
- data/lib/polars/selector.rb +72 -0
- data/lib/polars/selectors.rb +3 -3
- data/lib/polars/series.rb +1051 -54
- data/lib/polars/string_expr.rb +411 -6
- data/lib/polars/string_name_space.rb +722 -49
- data/lib/polars/struct_expr.rb +103 -0
- data/lib/polars/struct_name_space.rb +19 -1
- data/lib/polars/utils/various.rb +18 -1
- data/lib/polars/utils.rb +5 -1
- data/lib/polars/version.rb +1 -1
- data/lib/polars.rb +2 -0
- 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
|
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
|
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
|
data/lib/polars/convert.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Polars
|
2
2
|
module Convert
|
3
|
-
# Construct a DataFrame from a
|
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
|
14
|
-
# * As
|
15
|
-
# * As
|
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
|
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
|
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.
|