polars-df 0.10.0-x86_64-linux-musl
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 +7 -0
- data/.yardopts +3 -0
- data/CHANGELOG.md +175 -0
- data/Cargo.lock +2536 -0
- data/Cargo.toml +6 -0
- data/LICENSE-THIRD-PARTY.txt +38726 -0
- data/LICENSE.txt +20 -0
- data/README.md +437 -0
- data/lib/polars/3.1/polars.so +0 -0
- data/lib/polars/3.2/polars.so +0 -0
- data/lib/polars/3.3/polars.so +0 -0
- data/lib/polars/array_expr.rb +537 -0
- data/lib/polars/array_name_space.rb +423 -0
- data/lib/polars/batched_csv_reader.rb +98 -0
- data/lib/polars/binary_expr.rb +77 -0
- data/lib/polars/binary_name_space.rb +66 -0
- data/lib/polars/cat_expr.rb +72 -0
- data/lib/polars/cat_name_space.rb +125 -0
- data/lib/polars/config.rb +530 -0
- data/lib/polars/convert.rb +93 -0
- data/lib/polars/data_frame.rb +5418 -0
- data/lib/polars/data_types.rb +466 -0
- data/lib/polars/date_time_expr.rb +1444 -0
- data/lib/polars/date_time_name_space.rb +1484 -0
- data/lib/polars/dynamic_group_by.rb +52 -0
- data/lib/polars/exceptions.rb +31 -0
- data/lib/polars/expr.rb +6105 -0
- data/lib/polars/expr_dispatch.rb +22 -0
- data/lib/polars/functions/aggregation/horizontal.rb +246 -0
- data/lib/polars/functions/aggregation/vertical.rb +282 -0
- data/lib/polars/functions/as_datatype.rb +248 -0
- data/lib/polars/functions/col.rb +47 -0
- data/lib/polars/functions/eager.rb +182 -0
- data/lib/polars/functions/lazy.rb +1280 -0
- data/lib/polars/functions/len.rb +49 -0
- data/lib/polars/functions/lit.rb +35 -0
- data/lib/polars/functions/random.rb +16 -0
- data/lib/polars/functions/range/date_range.rb +103 -0
- data/lib/polars/functions/range/int_range.rb +51 -0
- data/lib/polars/functions/repeat.rb +144 -0
- data/lib/polars/functions/whenthen.rb +96 -0
- data/lib/polars/functions.rb +57 -0
- data/lib/polars/group_by.rb +548 -0
- data/lib/polars/io.rb +890 -0
- data/lib/polars/lazy_frame.rb +2833 -0
- data/lib/polars/lazy_group_by.rb +84 -0
- data/lib/polars/list_expr.rb +791 -0
- data/lib/polars/list_name_space.rb +445 -0
- data/lib/polars/meta_expr.rb +222 -0
- data/lib/polars/name_expr.rb +198 -0
- data/lib/polars/plot.rb +109 -0
- data/lib/polars/rolling_group_by.rb +37 -0
- data/lib/polars/series.rb +4527 -0
- data/lib/polars/slice.rb +104 -0
- data/lib/polars/sql_context.rb +194 -0
- data/lib/polars/string_cache.rb +75 -0
- data/lib/polars/string_expr.rb +1519 -0
- data/lib/polars/string_name_space.rb +810 -0
- data/lib/polars/struct_expr.rb +98 -0
- data/lib/polars/struct_name_space.rb +96 -0
- data/lib/polars/testing.rb +507 -0
- data/lib/polars/utils.rb +422 -0
- data/lib/polars/version.rb +4 -0
- data/lib/polars/whenthen.rb +83 -0
- data/lib/polars-df.rb +1 -0
- data/lib/polars.rb +72 -0
- metadata +125 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
module Polars
|
2
|
+
# Created by `df.lazy.group_by("foo")`.
|
3
|
+
class LazyGroupBy
|
4
|
+
# @private
|
5
|
+
def initialize(lgb)
|
6
|
+
@lgb = lgb
|
7
|
+
end
|
8
|
+
|
9
|
+
# Describe the aggregation that need to be done on a group.
|
10
|
+
#
|
11
|
+
# @return [LazyFrame]
|
12
|
+
def agg(aggs)
|
13
|
+
rbexprs = Utils.selection_to_rbexpr_list(aggs)
|
14
|
+
Utils.wrap_ldf(@lgb.agg(rbexprs))
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get the first `n` rows of each group.
|
18
|
+
#
|
19
|
+
# @param n [Integer]
|
20
|
+
# Number of rows to return.
|
21
|
+
#
|
22
|
+
# @return [LazyFrame]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# df = Polars::DataFrame.new(
|
26
|
+
# {
|
27
|
+
# "letters" => ["c", "c", "a", "c", "a", "b"],
|
28
|
+
# "nrs" => [1, 2, 3, 4, 5, 6]
|
29
|
+
# }
|
30
|
+
# )
|
31
|
+
# df.group_by("letters").head(2).sort("letters")
|
32
|
+
# # =>
|
33
|
+
# # shape: (5, 2)
|
34
|
+
# # ┌─────────┬─────┐
|
35
|
+
# # │ letters ┆ nrs │
|
36
|
+
# # │ --- ┆ --- │
|
37
|
+
# # │ str ┆ i64 │
|
38
|
+
# # ╞═════════╪═════╡
|
39
|
+
# # │ a ┆ 3 │
|
40
|
+
# # │ a ┆ 5 │
|
41
|
+
# # │ b ┆ 6 │
|
42
|
+
# # │ c ┆ 1 │
|
43
|
+
# # │ c ┆ 2 │
|
44
|
+
# # └─────────┴─────┘
|
45
|
+
def head(n = 5)
|
46
|
+
Utils.wrap_ldf(@lgb.head(n))
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get the last `n` rows of each group.
|
50
|
+
#
|
51
|
+
# @param n [Integer]
|
52
|
+
# Number of rows to return.
|
53
|
+
#
|
54
|
+
# @return [LazyFrame]
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# df = Polars::DataFrame.new(
|
58
|
+
# {
|
59
|
+
# "letters" => ["c", "c", "a", "c", "a", "b"],
|
60
|
+
# "nrs" => [1, 2, 3, 4, 5, 6]
|
61
|
+
# }
|
62
|
+
# )
|
63
|
+
# df.group_by("letters").tail(2).sort("letters")
|
64
|
+
# # =>
|
65
|
+
# # shape: (5, 2)
|
66
|
+
# # ┌─────────┬─────┐
|
67
|
+
# # │ letters ┆ nrs │
|
68
|
+
# # │ --- ┆ --- │
|
69
|
+
# # │ str ┆ i64 │
|
70
|
+
# # ╞═════════╪═════╡
|
71
|
+
# # │ a ┆ 3 │
|
72
|
+
# # │ a ┆ 5 │
|
73
|
+
# # │ b ┆ 6 │
|
74
|
+
# # │ c ┆ 2 │
|
75
|
+
# # │ c ┆ 4 │
|
76
|
+
# # └─────────┴─────┘
|
77
|
+
def tail(n = 5)
|
78
|
+
Utils.wrap_ldf(@lgb.tail(n))
|
79
|
+
end
|
80
|
+
|
81
|
+
# def apply
|
82
|
+
# end
|
83
|
+
end
|
84
|
+
end
|