polars-df 0.10.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/Cargo.lock +392 -351
- data/README.md +6 -6
- data/ext/polars/Cargo.toml +12 -7
- data/ext/polars/src/batched_csv.rs +53 -52
- data/ext/polars/src/conversion/any_value.rs +261 -0
- data/ext/polars/src/conversion/chunked_array.rs +4 -4
- data/ext/polars/src/conversion/mod.rs +60 -66
- data/ext/polars/src/dataframe/construction.rs +184 -0
- data/ext/polars/src/dataframe/export.rs +48 -0
- data/ext/polars/src/dataframe/general.rs +597 -0
- data/ext/polars/src/dataframe/io.rs +473 -0
- data/ext/polars/src/dataframe/mod.rs +26 -0
- data/ext/polars/src/error.rs +26 -4
- data/ext/polars/src/expr/categorical.rs +0 -10
- data/ext/polars/src/expr/datetime.rs +4 -8
- data/ext/polars/src/expr/general.rs +129 -94
- data/ext/polars/src/expr/mod.rs +2 -2
- data/ext/polars/src/expr/rolling.rs +201 -77
- data/ext/polars/src/expr/string.rs +11 -36
- data/ext/polars/src/functions/eager.rs +10 -10
- data/ext/polars/src/functions/lazy.rs +23 -21
- data/ext/polars/src/functions/range.rs +69 -1
- data/ext/polars/src/interop/mod.rs +1 -0
- data/ext/polars/src/interop/numo/mod.rs +2 -0
- data/ext/polars/src/interop/numo/to_numo_df.rs +23 -0
- data/ext/polars/src/interop/numo/to_numo_series.rs +61 -0
- data/ext/polars/src/lazyframe/mod.rs +135 -136
- data/ext/polars/src/lib.rs +94 -59
- data/ext/polars/src/map/dataframe.rs +2 -2
- data/ext/polars/src/map/lazy.rs +5 -25
- data/ext/polars/src/map/series.rs +7 -1
- data/ext/polars/src/rb_modules.rs +25 -1
- data/ext/polars/src/series/aggregation.rs +49 -30
- data/ext/polars/src/series/arithmetic.rs +21 -11
- data/ext/polars/src/series/construction.rs +56 -38
- data/ext/polars/src/series/export.rs +131 -49
- data/ext/polars/src/series/mod.rs +32 -141
- data/ext/polars/src/sql.rs +3 -1
- data/lib/polars/array_expr.rb +4 -4
- data/lib/polars/batched_csv_reader.rb +11 -5
- data/lib/polars/cat_expr.rb +0 -36
- data/lib/polars/cat_name_space.rb +0 -37
- data/lib/polars/convert.rb +6 -1
- data/lib/polars/data_frame.rb +176 -403
- data/lib/polars/data_types.rb +1 -1
- data/lib/polars/date_time_expr.rb +525 -572
- data/lib/polars/date_time_name_space.rb +263 -460
- data/lib/polars/dynamic_group_by.rb +5 -5
- data/lib/polars/exceptions.rb +7 -0
- data/lib/polars/expr.rb +1394 -243
- data/lib/polars/expr_dispatch.rb +1 -1
- data/lib/polars/functions/aggregation/horizontal.rb +8 -8
- data/lib/polars/functions/as_datatype.rb +63 -40
- data/lib/polars/functions/lazy.rb +63 -14
- data/lib/polars/functions/lit.rb +1 -1
- data/lib/polars/functions/range/date_range.rb +90 -57
- data/lib/polars/functions/range/datetime_range.rb +149 -0
- data/lib/polars/functions/range/int_range.rb +2 -2
- data/lib/polars/functions/range/time_range.rb +141 -0
- data/lib/polars/functions/repeat.rb +1 -1
- data/lib/polars/functions/whenthen.rb +1 -1
- data/lib/polars/group_by.rb +88 -23
- data/lib/polars/io/avro.rb +24 -0
- data/lib/polars/{io.rb → io/csv.rb} +299 -493
- data/lib/polars/io/database.rb +73 -0
- data/lib/polars/io/ipc.rb +247 -0
- data/lib/polars/io/json.rb +29 -0
- data/lib/polars/io/ndjson.rb +80 -0
- data/lib/polars/io/parquet.rb +227 -0
- data/lib/polars/lazy_frame.rb +143 -272
- data/lib/polars/lazy_group_by.rb +100 -3
- data/lib/polars/list_expr.rb +11 -11
- data/lib/polars/list_name_space.rb +5 -1
- data/lib/polars/rolling_group_by.rb +7 -9
- data/lib/polars/series.rb +103 -187
- data/lib/polars/string_expr.rb +78 -102
- data/lib/polars/string_name_space.rb +5 -4
- data/lib/polars/testing.rb +2 -2
- data/lib/polars/utils/constants.rb +9 -0
- data/lib/polars/utils/convert.rb +97 -0
- data/lib/polars/utils/parse.rb +89 -0
- data/lib/polars/utils/various.rb +76 -0
- data/lib/polars/utils/wrap.rb +19 -0
- data/lib/polars/utils.rb +8 -300
- data/lib/polars/version.rb +1 -1
- data/lib/polars/whenthen.rb +6 -6
- data/lib/polars.rb +20 -1
- metadata +28 -7
- data/ext/polars/src/conversion/anyvalue.rs +0 -186
- data/ext/polars/src/dataframe.rs +0 -1208
data/lib/polars/cat_expr.rb
CHANGED
@@ -9,42 +9,6 @@ module Polars
|
|
9
9
|
self._rbexpr = expr._rbexpr
|
10
10
|
end
|
11
11
|
|
12
|
-
# Determine how this categorical series should be sorted.
|
13
|
-
#
|
14
|
-
# @param ordering ["physical", "lexical"]
|
15
|
-
# Ordering type:
|
16
|
-
#
|
17
|
-
# - 'physical' -> Use the physical representation of the categories to determine the order (default).
|
18
|
-
# - 'lexical' -> Use the string values to determine the ordering.
|
19
|
-
#
|
20
|
-
# @return [Expr]
|
21
|
-
#
|
22
|
-
# @example
|
23
|
-
# df = Polars::DataFrame.new(
|
24
|
-
# {"cats" => ["z", "z", "k", "a", "b"], "vals" => [3, 1, 2, 2, 3]}
|
25
|
-
# ).with_columns(
|
26
|
-
# [
|
27
|
-
# Polars.col("cats").cast(:cat).cat.set_ordering("lexical")
|
28
|
-
# ]
|
29
|
-
# )
|
30
|
-
# df.sort(["cats", "vals"])
|
31
|
-
# # =>
|
32
|
-
# # shape: (5, 2)
|
33
|
-
# # ┌──────┬──────┐
|
34
|
-
# # │ cats ┆ vals │
|
35
|
-
# # │ --- ┆ --- │
|
36
|
-
# # │ cat ┆ i64 │
|
37
|
-
# # ╞══════╪══════╡
|
38
|
-
# # │ a ┆ 2 │
|
39
|
-
# # │ b ┆ 3 │
|
40
|
-
# # │ k ┆ 2 │
|
41
|
-
# # │ z ┆ 1 │
|
42
|
-
# # │ z ┆ 3 │
|
43
|
-
# # └──────┴──────┘
|
44
|
-
def set_ordering(ordering)
|
45
|
-
Utils.wrap_expr(_rbexpr.cat_set_ordering(ordering))
|
46
|
-
end
|
47
|
-
|
48
12
|
# Get the categories stored in this data type.
|
49
13
|
#
|
50
14
|
# @return [Expr]
|
@@ -10,43 +10,6 @@ module Polars
|
|
10
10
|
self._s = series._s
|
11
11
|
end
|
12
12
|
|
13
|
-
# Determine how this categorical series should be sorted.
|
14
|
-
#
|
15
|
-
# @param ordering ["physical", "lexical"]
|
16
|
-
# Ordering type:
|
17
|
-
#
|
18
|
-
# - 'physical' -> Use the physical representation of the categories to
|
19
|
-
# determine the order (default).
|
20
|
-
# - 'lexical' -> Use the string values to determine the ordering.
|
21
|
-
#
|
22
|
-
# @return [Series]
|
23
|
-
#
|
24
|
-
# @example
|
25
|
-
# df = Polars::DataFrame.new(
|
26
|
-
# {"cats" => ["z", "z", "k", "a", "b"], "vals" => [3, 1, 2, 2, 3]}
|
27
|
-
# ).with_columns(
|
28
|
-
# [
|
29
|
-
# Polars.col("cats").cast(:cat).cat.set_ordering("lexical")
|
30
|
-
# ]
|
31
|
-
# )
|
32
|
-
# df.sort(["cats", "vals"])
|
33
|
-
# # =>
|
34
|
-
# # shape: (5, 2)
|
35
|
-
# # ┌──────┬──────┐
|
36
|
-
# # │ cats ┆ vals │
|
37
|
-
# # │ --- ┆ --- │
|
38
|
-
# # │ cat ┆ i64 │
|
39
|
-
# # ╞══════╪══════╡
|
40
|
-
# # │ a ┆ 2 │
|
41
|
-
# # │ b ┆ 3 │
|
42
|
-
# # │ k ┆ 2 │
|
43
|
-
# # │ z ┆ 1 │
|
44
|
-
# # │ z ┆ 3 │
|
45
|
-
# # └──────┴──────┘
|
46
|
-
def set_ordering(ordering)
|
47
|
-
super
|
48
|
-
end
|
49
|
-
|
50
13
|
# Get the categories stored in this data type.
|
51
14
|
#
|
52
15
|
# @return [Series]
|
data/lib/polars/convert.rb
CHANGED
@@ -27,7 +27,12 @@ module Polars
|
|
27
27
|
# # │ 2 ┆ 4 │
|
28
28
|
# # └─────┴─────┘
|
29
29
|
def from_hash(data, schema: nil, columns: nil)
|
30
|
-
|
30
|
+
Utils.wrap_df(
|
31
|
+
DataFrame.hash_to_rbdf(
|
32
|
+
data,
|
33
|
+
schema: schema || columns
|
34
|
+
)
|
35
|
+
)
|
31
36
|
end
|
32
37
|
|
33
38
|
# Construct a DataFrame from a sequence of dictionaries. This operation clones data.
|