polars-df 0.9.0-x86_64-darwin → 0.11.0-x86_64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/Cargo.lock +144 -57
- data/LICENSE-THIRD-PARTY.txt +629 -29
- data/README.md +7 -6
- data/lib/polars/3.1/polars.bundle +0 -0
- data/lib/polars/3.2/polars.bundle +0 -0
- data/lib/polars/3.3/polars.bundle +0 -0
- data/lib/polars/array_expr.rb +6 -2
- data/lib/polars/batched_csv_reader.rb +11 -3
- data/lib/polars/convert.rb +6 -1
- data/lib/polars/data_frame.rb +225 -370
- data/lib/polars/date_time_expr.rb +11 -4
- data/lib/polars/date_time_name_space.rb +14 -4
- data/lib/polars/dynamic_group_by.rb +2 -2
- data/lib/polars/exceptions.rb +4 -0
- data/lib/polars/expr.rb +1171 -54
- data/lib/polars/functions/lazy.rb +3 -3
- data/lib/polars/functions/range/date_range.rb +92 -0
- data/lib/polars/functions/range/datetime_range.rb +149 -0
- data/lib/polars/functions/range/time_range.rb +141 -0
- data/lib/polars/functions/whenthen.rb +74 -5
- data/lib/polars/group_by.rb +88 -23
- data/lib/polars/io/avro.rb +24 -0
- data/lib/polars/{io.rb → io/csv.rb} +307 -489
- data/lib/polars/io/database.rb +73 -0
- data/lib/polars/io/ipc.rb +247 -0
- data/lib/polars/io/json.rb +18 -0
- data/lib/polars/io/ndjson.rb +69 -0
- data/lib/polars/io/parquet.rb +226 -0
- data/lib/polars/lazy_frame.rb +55 -195
- data/lib/polars/lazy_group_by.rb +100 -3
- data/lib/polars/list_expr.rb +6 -2
- data/lib/polars/rolling_group_by.rb +2 -2
- data/lib/polars/series.rb +14 -12
- data/lib/polars/string_expr.rb +38 -36
- data/lib/polars/utils.rb +89 -1
- data/lib/polars/version.rb +1 -1
- data/lib/polars/whenthen.rb +83 -0
- data/lib/polars.rb +10 -3
- metadata +13 -6
- data/lib/polars/when.rb +0 -16
- data/lib/polars/when_then.rb +0 -19
@@ -215,6 +215,7 @@ module Polars
|
|
215
215
|
offset = "0ns"
|
216
216
|
end
|
217
217
|
|
218
|
+
every = Utils.parse_as_expression(every, str_as_lit: true)
|
218
219
|
Utils.wrap_expr(
|
219
220
|
_rbexpr.dt_round(
|
220
221
|
Utils._timedelta_to_pl_duration(every),
|
@@ -1027,14 +1028,20 @@ module Polars
|
|
1027
1028
|
# Different from `convert_time_zone`, this will also modify
|
1028
1029
|
# the underlying timestamp,
|
1029
1030
|
#
|
1030
|
-
# @param
|
1031
|
-
#
|
1031
|
+
# @param time_zone [String]
|
1032
|
+
# Time zone for the `Datetime` Series. Pass `nil` to unset time zone.
|
1033
|
+
# @param use_earliest [Boolean]
|
1034
|
+
# Determine how to deal with ambiguous datetimes.
|
1035
|
+
# @param ambiguous [String]
|
1036
|
+
# Determine how to deal with ambiguous datetimes.
|
1037
|
+
# @param non_existent [String]
|
1038
|
+
# Determine how to deal with non-existent datetimes.
|
1032
1039
|
#
|
1033
1040
|
# @return [Expr]
|
1034
|
-
def replace_time_zone(
|
1041
|
+
def replace_time_zone(time_zone, use_earliest: nil, ambiguous: "raise", non_existent: "raise")
|
1035
1042
|
ambiguous = Utils.rename_use_earliest_to_ambiguous(use_earliest, ambiguous)
|
1036
1043
|
ambiguous = Polars.lit(ambiguous) unless ambiguous.is_a?(Expr)
|
1037
|
-
Utils.wrap_expr(_rbexpr.dt_replace_time_zone(
|
1044
|
+
Utils.wrap_expr(_rbexpr.dt_replace_time_zone(time_zone, ambiguous._rbexpr, non_existent))
|
1038
1045
|
end
|
1039
1046
|
|
1040
1047
|
# Extract the days from a Duration type.
|
@@ -66,6 +66,8 @@ module Polars
|
|
66
66
|
if !out.nil?
|
67
67
|
if s.dtype == Date
|
68
68
|
return Utils._to_ruby_date(out.to_i)
|
69
|
+
elsif [Datetime, Duration, Time].include?(s.dtype)
|
70
|
+
return out
|
69
71
|
else
|
70
72
|
return Utils._to_ruby_datetime(out.to_i, s.time_unit)
|
71
73
|
end
|
@@ -93,10 +95,12 @@ module Polars
|
|
93
95
|
# # => 2001-01-02 00:00:00 UTC
|
94
96
|
def mean
|
95
97
|
s = Utils.wrap_s(_s)
|
96
|
-
out = s.mean
|
98
|
+
out = s.mean
|
97
99
|
if !out.nil?
|
98
100
|
if s.dtype == Date
|
99
101
|
return Utils._to_ruby_date(out.to_i)
|
102
|
+
elsif [Datetime, Duration, Time].include?(s.dtype)
|
103
|
+
return out
|
100
104
|
else
|
101
105
|
return Utils._to_ruby_datetime(out.to_i, s.time_unit)
|
102
106
|
end
|
@@ -910,8 +914,14 @@ module Polars
|
|
910
914
|
# Different from `with_time_zone`, this will also modify
|
911
915
|
# the underlying timestamp.
|
912
916
|
#
|
913
|
-
# @param
|
914
|
-
#
|
917
|
+
# @param time_zone [String]
|
918
|
+
# Time zone for the `Datetime` Series. Pass `nil` to unset time zone.
|
919
|
+
# @param use_earliest [Boolean]
|
920
|
+
# Determine how to deal with ambiguous datetimes.
|
921
|
+
# @param ambiguous [String]
|
922
|
+
# Determine how to deal with ambiguous datetimes.
|
923
|
+
# @param non_existent [String]
|
924
|
+
# Determine how to deal with non-existent datetimes.
|
915
925
|
#
|
916
926
|
# @return [Series]
|
917
927
|
#
|
@@ -982,7 +992,7 @@ module Polars
|
|
982
992
|
# # 1585717200
|
983
993
|
# # 1588309200
|
984
994
|
# # ]
|
985
|
-
def replace_time_zone(
|
995
|
+
def replace_time_zone(time_zone, use_earliest: nil, ambiguous: "raise", non_existent: "raise")
|
986
996
|
super
|
987
997
|
end
|
988
998
|
|
@@ -32,7 +32,7 @@ module Polars
|
|
32
32
|
@start_by = start_by
|
33
33
|
end
|
34
34
|
|
35
|
-
def agg(aggs)
|
35
|
+
def agg(*aggs, **named_aggs)
|
36
36
|
@df.lazy
|
37
37
|
.group_by_dynamic(
|
38
38
|
@time_column,
|
@@ -45,7 +45,7 @@ module Polars
|
|
45
45
|
by: @by,
|
46
46
|
start_by: @start_by
|
47
47
|
)
|
48
|
-
.agg(aggs)
|
48
|
+
.agg(*aggs, **named_aggs)
|
49
49
|
.collect(no_optimization: true, string_cache: false)
|
50
50
|
end
|
51
51
|
end
|
data/lib/polars/exceptions.rb
CHANGED
@@ -3,6 +3,10 @@ module Polars
|
|
3
3
|
# Base class for all Polars errors.
|
4
4
|
class Error < StandardError; end
|
5
5
|
|
6
|
+
# @private
|
7
|
+
# Exception raised when an operation is not allowed (or possible) against a given object or data structure.
|
8
|
+
class InvalidOperationError < Error; end
|
9
|
+
|
6
10
|
# @private
|
7
11
|
# Exception raised when an unsupported testing assert is made.
|
8
12
|
class InvalidAssert < Error; end
|