polars-df 0.2.4-x86_64-linux → 0.3.0-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Cargo.lock +290 -137
- data/Cargo.toml +1 -1
- data/LICENSE-THIRD-PARTY.txt +1593 -979
- data/README.md +3 -3
- data/lib/polars/3.0/polars.so +0 -0
- data/lib/polars/3.1/polars.so +0 -0
- data/lib/polars/3.2/polars.so +0 -0
- data/lib/polars/batched_csv_reader.rb +1 -1
- data/lib/polars/cat_expr.rb +0 -4
- data/lib/polars/cat_name_space.rb +0 -4
- data/lib/polars/convert.rb +0 -7
- data/lib/polars/data_frame.rb +184 -217
- data/lib/polars/date_time_expr.rb +19 -151
- data/lib/polars/date_time_name_space.rb +17 -17
- data/lib/polars/expr.rb +68 -315
- data/lib/polars/group_by.rb +68 -51
- data/lib/polars/io.rb +7 -7
- data/lib/polars/lazy_frame.rb +4 -106
- data/lib/polars/lazy_functions.rb +14 -40
- data/lib/polars/lazy_group_by.rb +0 -8
- data/lib/polars/list_expr.rb +5 -27
- data/lib/polars/list_name_space.rb +5 -8
- data/lib/polars/series.rb +20 -16
- data/lib/polars/string_expr.rb +20 -76
- data/lib/polars/string_name_space.rb +5 -15
- data/lib/polars/struct_expr.rb +0 -2
- data/lib/polars/utils.rb +8 -0
- data/lib/polars/version.rb +1 -1
- metadata +2 -2
@@ -15,7 +15,7 @@ module Polars
|
|
15
15
|
if name.is_a?(DataType)
|
16
16
|
Utils.wrap_expr(_dtype_cols([name]))
|
17
17
|
elsif name.is_a?(Array)
|
18
|
-
if name.length == 0 ||
|
18
|
+
if name.length == 0 || Utils.strlike?(name[0])
|
19
19
|
name = name.map { |v| v.is_a?(Symbol) ? v.to_s : v }
|
20
20
|
Utils.wrap_expr(RbExpr.cols(name))
|
21
21
|
elsif Utils.is_polars_dtype(name[0])
|
@@ -46,9 +46,7 @@ module Polars
|
|
46
46
|
# # │ i64 ┆ i64 ┆ list[f32] │
|
47
47
|
# # ╞═════╪═════╪════════════╡
|
48
48
|
# # │ 1 ┆ 4 ┆ [1.0, 2.0] │
|
49
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
|
50
49
|
# # │ 8 ┆ 5 ┆ [2.0, 1.0] │
|
51
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
|
52
50
|
# # │ 3 ┆ 2 ┆ [2.0, 1.0] │
|
53
51
|
# # └─────┴─────┴────────────┘
|
54
52
|
def element
|
@@ -119,7 +117,7 @@ module Polars
|
|
119
117
|
def max(column)
|
120
118
|
if column.is_a?(Series)
|
121
119
|
column.max
|
122
|
-
elsif
|
120
|
+
elsif Utils.strlike?(column)
|
123
121
|
col(column).max
|
124
122
|
else
|
125
123
|
exprs = Utils.selection_to_rbexpr_list(column)
|
@@ -141,7 +139,7 @@ module Polars
|
|
141
139
|
def min(column)
|
142
140
|
if column.is_a?(Series)
|
143
141
|
column.min
|
144
|
-
elsif
|
142
|
+
elsif Utils.strlike?(column)
|
145
143
|
col(column).min
|
146
144
|
else
|
147
145
|
exprs = Utils.selection_to_rbexpr_list(column)
|
@@ -156,7 +154,7 @@ module Polars
|
|
156
154
|
def sum(column)
|
157
155
|
if column.is_a?(Series)
|
158
156
|
column.sum
|
159
|
-
elsif
|
157
|
+
elsif Utils.strlike?(column)
|
160
158
|
col(column.to_s).sum
|
161
159
|
elsif column.is_a?(Array)
|
162
160
|
exprs = Utils.selection_to_rbexpr_list(column)
|
@@ -322,7 +320,6 @@ module Polars
|
|
322
320
|
# # │ i64 ┆ i64 ┆ i64 │
|
323
321
|
# # ╞═════╪═════╪═════╡
|
324
322
|
# # │ 1 ┆ 3 ┆ 5 │
|
325
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
|
326
323
|
# # │ 2 ┆ 4 ┆ 6 │
|
327
324
|
# # └─────┴─────┴─────┘
|
328
325
|
#
|
@@ -336,7 +333,6 @@ module Polars
|
|
336
333
|
# # │ i64 │
|
337
334
|
# # ╞═════╡
|
338
335
|
# # │ 1 │
|
339
|
-
# # ├╌╌╌╌╌┤
|
340
336
|
# # │ 3 │
|
341
337
|
# # └─────┘
|
342
338
|
#
|
@@ -350,13 +346,12 @@ module Polars
|
|
350
346
|
# # │ i64 ┆ i64 ┆ i64 ┆ struct[2] │
|
351
347
|
# # ╞═════╪═════╪═════╪═══════════╡
|
352
348
|
# # │ 1 ┆ 3 ┆ 5 ┆ {1,6} │
|
353
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
|
354
349
|
# # │ 2 ┆ 4 ┆ 6 ┆ {2,8} │
|
355
350
|
# # └─────┴─────┴─────┴───────────┘
|
356
351
|
def cumsum(column)
|
357
352
|
if column.is_a?(Series)
|
358
353
|
column.cumsum
|
359
|
-
elsif
|
354
|
+
elsif Utils.strlike?(column)
|
360
355
|
col(column).cumsum
|
361
356
|
else
|
362
357
|
cumfold(lit(0).cast(:u32), ->(a, b) { a + b }, column).alias("cumsum")
|
@@ -380,10 +375,10 @@ module Polars
|
|
380
375
|
#
|
381
376
|
# @return [Expr]
|
382
377
|
def spearman_rank_corr(a, b, ddof: 1, propagate_nans: false)
|
383
|
-
if
|
378
|
+
if Utils.strlike?(a)
|
384
379
|
a = col(a)
|
385
380
|
end
|
386
|
-
if
|
381
|
+
if Utils.strlike?(b)
|
387
382
|
b = col(b)
|
388
383
|
end
|
389
384
|
Utils.wrap_expr(RbExpr.spearman_rank_corr(a._rbexpr, b._rbexpr, ddof, propagate_nans))
|
@@ -400,10 +395,10 @@ module Polars
|
|
400
395
|
#
|
401
396
|
# @return [Expr]
|
402
397
|
def pearson_corr(a, b, ddof: 1)
|
403
|
-
if
|
398
|
+
if Utils.strlike?(a)
|
404
399
|
a = col(a)
|
405
400
|
end
|
406
|
-
if
|
401
|
+
if Utils.strlike?(b)
|
407
402
|
b = col(b)
|
408
403
|
end
|
409
404
|
Utils.wrap_expr(RbExpr.pearson_corr(a._rbexpr, b._rbexpr, ddof))
|
@@ -418,10 +413,10 @@ module Polars
|
|
418
413
|
#
|
419
414
|
# @return [Expr]
|
420
415
|
def cov(a, b)
|
421
|
-
if
|
416
|
+
if Utils.strlike?(a)
|
422
417
|
a = col(a)
|
423
418
|
end
|
424
|
-
if
|
419
|
+
if Utils.strlike?(b)
|
425
420
|
b = col(b)
|
426
421
|
end
|
427
422
|
Utils.wrap_expr(RbExpr.cov(a._rbexpr, b._rbexpr))
|
@@ -486,7 +481,7 @@ module Polars
|
|
486
481
|
#
|
487
482
|
# @return [Expr]
|
488
483
|
def any(name)
|
489
|
-
if
|
484
|
+
if Utils.strlike?(name)
|
490
485
|
col(name).any
|
491
486
|
else
|
492
487
|
fold(lit(false), ->(a, b) { a.cast(:bool) | b.cast(:bool) }, name).alias("any")
|
@@ -521,9 +516,7 @@ module Polars
|
|
521
516
|
# # │ i64 ┆ str ┆ f64 │
|
522
517
|
# # ╞═════╪══════╪══════╡
|
523
518
|
# # │ 1 ┆ a ┆ null │
|
524
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
|
525
519
|
# # │ 2 ┆ b ┆ 2.5 │
|
526
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
|
527
520
|
# # │ 3 ┆ null ┆ 1.5 │
|
528
521
|
# # └─────┴──────┴──────┘
|
529
522
|
#
|
@@ -537,9 +530,7 @@ module Polars
|
|
537
530
|
# # │ i64 ┆ f64 │
|
538
531
|
# # ╞═════╪══════╡
|
539
532
|
# # │ 1 ┆ null │
|
540
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
|
541
533
|
# # │ 2 ┆ 2.5 │
|
542
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
|
543
534
|
# # │ 3 ┆ 1.5 │
|
544
535
|
# # └─────┴──────┘
|
545
536
|
#
|
@@ -553,9 +544,7 @@ module Polars
|
|
553
544
|
# # │ f64 │
|
554
545
|
# # ╞══════╡
|
555
546
|
# # │ null │
|
556
|
-
# # ├╌╌╌╌╌╌┤
|
557
547
|
# # │ 2.5 │
|
558
|
-
# # ├╌╌╌╌╌╌┤
|
559
548
|
# # │ 1.5 │
|
560
549
|
# # └──────┘
|
561
550
|
def exclude(columns)
|
@@ -589,7 +578,7 @@ module Polars
|
|
589
578
|
def all(name = nil)
|
590
579
|
if name.nil?
|
591
580
|
col("*")
|
592
|
-
elsif
|
581
|
+
elsif Utils.strlike?(name)
|
593
582
|
col(name).all
|
594
583
|
else
|
595
584
|
raise Todo
|
@@ -709,7 +698,6 @@ module Polars
|
|
709
698
|
# # │ datetime[ns] ┆ datetime[ns] ┆ datetime[ns] ┆ datetime[ns] ┆ datetime[ns] │
|
710
699
|
# # ╞═════════════════════╪═════════════════════╪═════════════════════╪═════════════════════════╪═════════════════════╡
|
711
700
|
# # │ 2022-01-08 00:00:00 ┆ 2022-01-02 00:00:00 ┆ 2022-01-01 00:00:01 ┆ 2022-01-01 00:00:00.001 ┆ 2022-01-01 01:00:00 │
|
712
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
713
701
|
# # │ 2022-01-16 00:00:00 ┆ 2022-01-04 00:00:00 ┆ 2022-01-02 00:00:02 ┆ 2022-01-02 00:00:00.002 ┆ 2022-01-02 02:00:00 │
|
714
702
|
# # └─────────────────────┴─────────────────────┴─────────────────────┴─────────────────────────┴─────────────────────┘
|
715
703
|
def duration(
|
@@ -798,9 +786,7 @@ module Polars
|
|
798
786
|
# # │ i64 ┆ str ┆ str ┆ str │
|
799
787
|
# # ╞═════╪══════╪══════╪═══════════════╡
|
800
788
|
# # │ 1 ┆ dogs ┆ play ┆ 2 dogs play │
|
801
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
802
789
|
# # │ 2 ┆ cats ┆ swim ┆ 4 cats swim │
|
803
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
804
790
|
# # │ 3 ┆ null ┆ walk ┆ null │
|
805
791
|
# # └─────┴──────┴──────┴───────────────┘
|
806
792
|
def concat_str(exprs, sep: "")
|
@@ -838,9 +824,7 @@ module Polars
|
|
838
824
|
# # │ str │
|
839
825
|
# # ╞═════════════╡
|
840
826
|
# # │ foo_a_bar_1 │
|
841
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
842
827
|
# # │ foo_b_bar_2 │
|
843
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
844
828
|
# # │ foo_c_bar_3 │
|
845
829
|
# # └─────────────┘
|
846
830
|
def format(fstring, *args)
|
@@ -972,7 +956,6 @@ module Polars
|
|
972
956
|
# # │ struct[4] │
|
973
957
|
# # ╞═════════════════════╡
|
974
958
|
# # │ {1,"a",true,[1, 2]} │
|
975
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
976
959
|
# # │ {2,"b",null,[3]} │
|
977
960
|
# # └─────────────────────┘
|
978
961
|
#
|
@@ -989,11 +972,8 @@ module Polars
|
|
989
972
|
# # │ i64 ┆ str ┆ i64 ┆ struct[2] │
|
990
973
|
# # ╞═════╪═══════╪═════╪═════════════╡
|
991
974
|
# # │ 1 ┆ one ┆ 9 ┆ {1,"one"} │
|
992
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
993
975
|
# # │ 2 ┆ two ┆ 8 ┆ {2,"two"} │
|
994
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
995
976
|
# # │ 3 ┆ three ┆ 7 ┆ {3,"three"} │
|
996
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
997
977
|
# # │ 4 ┆ four ┆ 6 ┆ {4,"four"} │
|
998
978
|
# # └─────┴───────┴─────┴─────────────┘
|
999
979
|
def struct(exprs, eager: false)
|
@@ -1092,11 +1072,8 @@ module Polars
|
|
1092
1072
|
# # │ f64 ┆ f64 ┆ f64 ┆ f64 │
|
1093
1073
|
# # ╞══════╪══════╪══════╪══════╡
|
1094
1074
|
# # │ null ┆ 1.0 ┆ 1.0 ┆ 1.0 │
|
1095
|
-
# # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
|
1096
1075
|
# # │ null ┆ 2.0 ┆ 2.0 ┆ 2.0 │
|
1097
|
-
# # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
|
1098
1076
|
# # │ null ┆ null ┆ 3.0 ┆ 3.0 │
|
1099
|
-
# # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
|
1100
1077
|
# # │ null ┆ null ┆ null ┆ 99.9 │
|
1101
1078
|
# # └──────┴──────┴──────┴──────┘
|
1102
1079
|
def coalesce(exprs)
|
@@ -1133,11 +1110,10 @@ module Polars
|
|
1133
1110
|
# # │ datetime[μs] │
|
1134
1111
|
# # ╞═════════════════════╡
|
1135
1112
|
# # │ 2022-10-25 07:31:17 │
|
1136
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
1137
1113
|
# # │ 2022-10-25 07:31:39 │
|
1138
1114
|
# # └─────────────────────┘
|
1139
1115
|
def from_epoch(column, unit: "s", eager: false)
|
1140
|
-
if
|
1116
|
+
if Utils.strlike?(column)
|
1141
1117
|
column = col(column)
|
1142
1118
|
elsif !column.is_a?(Series) && !column.is_a?(Expr)
|
1143
1119
|
column = Series.new(column)
|
@@ -1181,9 +1157,7 @@ module Polars
|
|
1181
1157
|
# # │ i64 ┆ i64 ┆ i32 │
|
1182
1158
|
# # ╞═════╪═════╪═════════╡
|
1183
1159
|
# # │ 1 ┆ 3 ┆ -1 │
|
1184
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
|
1185
1160
|
# # │ 3 ┆ 4 ┆ 1 │
|
1186
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
|
1187
1161
|
# # │ 4 ┆ 0 ┆ 1 │
|
1188
1162
|
# # └─────┴─────┴─────────┘
|
1189
1163
|
def when(expr)
|
data/lib/polars/lazy_group_by.rb
CHANGED
@@ -38,13 +38,9 @@ module Polars
|
|
38
38
|
# # │ str ┆ i64 │
|
39
39
|
# # ╞═════════╪═════╡
|
40
40
|
# # │ a ┆ 3 │
|
41
|
-
# # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
|
42
41
|
# # │ a ┆ 5 │
|
43
|
-
# # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
|
44
42
|
# # │ b ┆ 6 │
|
45
|
-
# # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
|
46
43
|
# # │ c ┆ 1 │
|
47
|
-
# # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
|
48
44
|
# # │ c ┆ 2 │
|
49
45
|
# # └─────────┴─────┘
|
50
46
|
def head(n = 5)
|
@@ -74,13 +70,9 @@ module Polars
|
|
74
70
|
# # │ str ┆ i64 │
|
75
71
|
# # ╞═════════╪═════╡
|
76
72
|
# # │ a ┆ 3 │
|
77
|
-
# # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
|
78
73
|
# # │ a ┆ 5 │
|
79
|
-
# # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
|
80
74
|
# # │ b ┆ 6 │
|
81
|
-
# # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
|
82
75
|
# # │ c ┆ 2 │
|
83
|
-
# # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
|
84
76
|
# # │ c ┆ 4 │
|
85
77
|
# # └─────────┴─────┘
|
86
78
|
def tail(n = 5)
|
data/lib/polars/list_expr.rb
CHANGED
@@ -24,7 +24,6 @@ module Polars
|
|
24
24
|
# # │ u32 │
|
25
25
|
# # ╞═════╡
|
26
26
|
# # │ 2 │
|
27
|
-
# # ├╌╌╌╌╌┤
|
28
27
|
# # │ 1 │
|
29
28
|
# # └─────┘
|
30
29
|
def lengths
|
@@ -46,7 +45,6 @@ module Polars
|
|
46
45
|
# # │ i64 │
|
47
46
|
# # ╞════════╡
|
48
47
|
# # │ 1 │
|
49
|
-
# # ├╌╌╌╌╌╌╌╌┤
|
50
48
|
# # │ 5 │
|
51
49
|
# # └────────┘
|
52
50
|
def sum
|
@@ -68,7 +66,6 @@ module Polars
|
|
68
66
|
# # │ i64 │
|
69
67
|
# # ╞════════╡
|
70
68
|
# # │ 1 │
|
71
|
-
# # ├╌╌╌╌╌╌╌╌┤
|
72
69
|
# # │ 3 │
|
73
70
|
# # └────────┘
|
74
71
|
def max
|
@@ -90,7 +87,6 @@ module Polars
|
|
90
87
|
# # │ i64 │
|
91
88
|
# # ╞════════╡
|
92
89
|
# # │ 1 │
|
93
|
-
# # ├╌╌╌╌╌╌╌╌┤
|
94
90
|
# # │ 2 │
|
95
91
|
# # └────────┘
|
96
92
|
def min
|
@@ -112,7 +108,6 @@ module Polars
|
|
112
108
|
# # │ f64 │
|
113
109
|
# # ╞════════╡
|
114
110
|
# # │ 1.0 │
|
115
|
-
# # ├╌╌╌╌╌╌╌╌┤
|
116
111
|
# # │ 2.5 │
|
117
112
|
# # └────────┘
|
118
113
|
def mean
|
@@ -138,7 +133,6 @@ module Polars
|
|
138
133
|
# # │ list[i64] │
|
139
134
|
# # ╞═══════════╡
|
140
135
|
# # │ [1, 2, 3] │
|
141
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌┤
|
142
136
|
# # │ [1, 2, 9] │
|
143
137
|
# # └───────────┘
|
144
138
|
def sort(reverse: false)
|
@@ -164,7 +158,6 @@ module Polars
|
|
164
158
|
# # │ list[i64] │
|
165
159
|
# # ╞═══════════╡
|
166
160
|
# # │ [1, 2, 3] │
|
167
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌┤
|
168
161
|
# # │ [2, 1, 9] │
|
169
162
|
# # └───────────┘
|
170
163
|
def reverse
|
@@ -218,7 +211,6 @@ module Polars
|
|
218
211
|
# # │ list[str] │
|
219
212
|
# # ╞═════════════════╡
|
220
213
|
# # │ ["a", "b", "c"] │
|
221
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
222
214
|
# # │ ["x", "y", "z"] │
|
223
215
|
# # └─────────────────┘
|
224
216
|
def concat(other)
|
@@ -258,9 +250,7 @@ module Polars
|
|
258
250
|
# # │ i64 │
|
259
251
|
# # ╞══════╡
|
260
252
|
# # │ 3 │
|
261
|
-
# # ├╌╌╌╌╌╌┤
|
262
253
|
# # │ null │
|
263
|
-
# # ├╌╌╌╌╌╌┤
|
264
254
|
# # │ 1 │
|
265
255
|
# # └──────┘
|
266
256
|
def get(index)
|
@@ -290,9 +280,7 @@ module Polars
|
|
290
280
|
# # │ i64 │
|
291
281
|
# # ╞══════╡
|
292
282
|
# # │ 3 │
|
293
|
-
# # ├╌╌╌╌╌╌┤
|
294
283
|
# # │ null │
|
295
|
-
# # ├╌╌╌╌╌╌┤
|
296
284
|
# # │ 1 │
|
297
285
|
# # └──────┘
|
298
286
|
def first
|
@@ -314,9 +302,7 @@ module Polars
|
|
314
302
|
# # │ i64 │
|
315
303
|
# # ╞══════╡
|
316
304
|
# # │ 1 │
|
317
|
-
# # ├╌╌╌╌╌╌┤
|
318
305
|
# # │ null │
|
319
|
-
# # ├╌╌╌╌╌╌┤
|
320
306
|
# # │ 2 │
|
321
307
|
# # └──────┘
|
322
308
|
def last
|
@@ -341,9 +327,7 @@ module Polars
|
|
341
327
|
# # │ bool │
|
342
328
|
# # ╞═══════╡
|
343
329
|
# # │ true │
|
344
|
-
# # ├╌╌╌╌╌╌╌┤
|
345
330
|
# # │ false │
|
346
|
-
# # ├╌╌╌╌╌╌╌┤
|
347
331
|
# # │ true │
|
348
332
|
# # └───────┘
|
349
333
|
def contains(item)
|
@@ -370,7 +354,6 @@ module Polars
|
|
370
354
|
# # │ str │
|
371
355
|
# # ╞═══════╡
|
372
356
|
# # │ a b c │
|
373
|
-
# # ├╌╌╌╌╌╌╌┤
|
374
357
|
# # │ x y │
|
375
358
|
# # └───────┘
|
376
359
|
def join(separator)
|
@@ -396,7 +379,6 @@ module Polars
|
|
396
379
|
# # │ u32 │
|
397
380
|
# # ╞═════╡
|
398
381
|
# # │ 0 │
|
399
|
-
# # ├╌╌╌╌╌┤
|
400
382
|
# # │ 1 │
|
401
383
|
# # └─────┘
|
402
384
|
def arg_min
|
@@ -422,7 +404,6 @@ module Polars
|
|
422
404
|
# # │ u32 │
|
423
405
|
# # ╞═════╡
|
424
406
|
# # │ 1 │
|
425
|
-
# # ├╌╌╌╌╌┤
|
426
407
|
# # │ 0 │
|
427
408
|
# # └─────┘
|
428
409
|
def arg_max
|
@@ -443,7 +424,7 @@ module Polars
|
|
443
424
|
# s.arr.diff
|
444
425
|
# # =>
|
445
426
|
# # shape: (2,)
|
446
|
-
# # Series: 'a' [list]
|
427
|
+
# # Series: 'a' [list[i64]]
|
447
428
|
# # [
|
448
429
|
# # [null, 1, ... 1]
|
449
430
|
# # [null, -8, -1]
|
@@ -464,7 +445,7 @@ module Polars
|
|
464
445
|
# s.arr.shift
|
465
446
|
# # =>
|
466
447
|
# # shape: (2,)
|
467
|
-
# # Series: 'a' [list]
|
448
|
+
# # Series: 'a' [list[i64]]
|
468
449
|
# # [
|
469
450
|
# # [null, 1, ... 3]
|
470
451
|
# # [null, 10, 2]
|
@@ -488,7 +469,7 @@ module Polars
|
|
488
469
|
# s.arr.slice(1, 2)
|
489
470
|
# # =>
|
490
471
|
# # shape: (2,)
|
491
|
-
# # Series: 'a' [list]
|
472
|
+
# # Series: 'a' [list[i64]]
|
492
473
|
# # [
|
493
474
|
# # [2, 3]
|
494
475
|
# # [2, 1]
|
@@ -511,7 +492,7 @@ module Polars
|
|
511
492
|
# s.arr.head(2)
|
512
493
|
# # =>
|
513
494
|
# # shape: (2,)
|
514
|
-
# # Series: 'a' [list]
|
495
|
+
# # Series: 'a' [list[i64]]
|
515
496
|
# # [
|
516
497
|
# # [1, 2]
|
517
498
|
# # [10, 2]
|
@@ -532,7 +513,7 @@ module Polars
|
|
532
513
|
# s.arr.tail(2)
|
533
514
|
# # =>
|
534
515
|
# # shape: (2,)
|
535
|
-
# # Series: 'a' [list]
|
516
|
+
# # Series: 'a' [list[i64]]
|
536
517
|
# # [
|
537
518
|
# # [3, 4]
|
538
519
|
# # [2, 1]
|
@@ -563,7 +544,6 @@ module Polars
|
|
563
544
|
# # │ struct[3] │
|
564
545
|
# # ╞════════════╡
|
565
546
|
# # │ {1,2,3} │
|
566
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌┤
|
567
547
|
# # │ {1,2,null} │
|
568
548
|
# # └────────────┘
|
569
549
|
def to_struct(n_field_strategy: "first_non_null", name_generator: nil)
|
@@ -598,9 +578,7 @@ module Polars
|
|
598
578
|
# # │ i64 ┆ i64 ┆ list[f32] │
|
599
579
|
# # ╞═════╪═════╪════════════╡
|
600
580
|
# # │ 1 ┆ 4 ┆ [1.0, 2.0] │
|
601
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
|
602
581
|
# # │ 8 ┆ 5 ┆ [2.0, 1.0] │
|
603
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
|
604
582
|
# # │ 3 ┆ 2 ┆ [2.0, 1.0] │
|
605
583
|
# # └─────┴─────┴────────────┘
|
606
584
|
def eval(expr, parallel: false)
|
@@ -183,7 +183,7 @@ module Polars
|
|
183
183
|
# s.arr.diff
|
184
184
|
# # =>
|
185
185
|
# # shape: (2,)
|
186
|
-
# # Series: 'a' [list]
|
186
|
+
# # Series: 'a' [list[i64]]
|
187
187
|
# # [
|
188
188
|
# # [null, 1, ... 1]
|
189
189
|
# # [null, -8, -1]
|
@@ -204,7 +204,7 @@ module Polars
|
|
204
204
|
# s.arr.shift
|
205
205
|
# # =>
|
206
206
|
# # shape: (2,)
|
207
|
-
# # Series: 'a' [list]
|
207
|
+
# # Series: 'a' [list[i64]]
|
208
208
|
# # [
|
209
209
|
# # [null, 1, ... 3]
|
210
210
|
# # [null, 10, 2]
|
@@ -228,7 +228,7 @@ module Polars
|
|
228
228
|
# s.arr.slice(1, 2)
|
229
229
|
# # =>
|
230
230
|
# # shape: (2,)
|
231
|
-
# # Series: 'a' [list]
|
231
|
+
# # Series: 'a' [list[i64]]
|
232
232
|
# # [
|
233
233
|
# # [2, 3]
|
234
234
|
# # [2, 1]
|
@@ -249,7 +249,7 @@ module Polars
|
|
249
249
|
# s.arr.head(2)
|
250
250
|
# # =>
|
251
251
|
# # shape: (2,)
|
252
|
-
# # Series: 'a' [list]
|
252
|
+
# # Series: 'a' [list[i64]]
|
253
253
|
# # [
|
254
254
|
# # [1, 2]
|
255
255
|
# # [10, 2]
|
@@ -270,7 +270,7 @@ module Polars
|
|
270
270
|
# s.arr.tail(2)
|
271
271
|
# # =>
|
272
272
|
# # shape: (2,)
|
273
|
-
# # Series: 'a' [list]
|
273
|
+
# # Series: 'a' [list[i64]]
|
274
274
|
# # [
|
275
275
|
# # [3, 4]
|
276
276
|
# # [2, 1]
|
@@ -300,7 +300,6 @@ module Polars
|
|
300
300
|
# # │ struct[3] │
|
301
301
|
# # ╞════════════╡
|
302
302
|
# # │ {1,2,3} │
|
303
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌┤
|
304
303
|
# # │ {1,2,null} │
|
305
304
|
# # └────────────┘
|
306
305
|
def to_struct(n_field_strategy: "first_non_null", name_generator: nil)
|
@@ -334,9 +333,7 @@ module Polars
|
|
334
333
|
# # │ i64 ┆ i64 ┆ list[f32] │
|
335
334
|
# # ╞═════╪═════╪════════════╡
|
336
335
|
# # │ 1 ┆ 4 ┆ [1.0, 2.0] │
|
337
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
|
338
336
|
# # │ 8 ┆ 5 ┆ [2.0, 1.0] │
|
339
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
|
340
337
|
# # │ 3 ┆ 2 ┆ [2.0, 1.0] │
|
341
338
|
# # └─────┴─────┴────────────┘
|
342
339
|
def eval(expr, parallel: false)
|
data/lib/polars/series.rb
CHANGED
@@ -259,6 +259,17 @@ module Polars
|
|
259
259
|
0 - self
|
260
260
|
end
|
261
261
|
|
262
|
+
# Returns an enumerator.
|
263
|
+
#
|
264
|
+
# @return [Object]
|
265
|
+
def each
|
266
|
+
return to_enum(:each) unless block_given?
|
267
|
+
|
268
|
+
length.times do |i|
|
269
|
+
yield self[i]
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
262
273
|
# Returns elements of the Series.
|
263
274
|
#
|
264
275
|
# @return [Object]
|
@@ -432,15 +443,10 @@ module Polars
|
|
432
443
|
# # │ str ┆ f64 │
|
433
444
|
# # ╞════════════╪══════════╡
|
434
445
|
# # │ min ┆ 1.0 │
|
435
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
|
436
446
|
# # │ max ┆ 5.0 │
|
437
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
|
438
447
|
# # │ null_count ┆ 0.0 │
|
439
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
|
440
448
|
# # │ mean ┆ 3.0 │
|
441
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
|
442
449
|
# # │ std ┆ 1.581139 │
|
443
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
|
444
450
|
# # │ count ┆ 5.0 │
|
445
451
|
# # └────────────┴──────────┘
|
446
452
|
#
|
@@ -455,9 +461,7 @@ module Polars
|
|
455
461
|
# # │ str ┆ i64 │
|
456
462
|
# # ╞════════════╪═══════╡
|
457
463
|
# # │ unique ┆ 4 │
|
458
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
|
459
464
|
# # │ null_count ┆ 1 │
|
460
|
-
# # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
|
461
465
|
# # │ count ┆ 5 │
|
462
466
|
# # └────────────┴───────┘
|
463
467
|
def describe
|
@@ -660,13 +664,11 @@ module Polars
|
|
660
664
|
# # │ u8 ┆ u8 ┆ u8 │
|
661
665
|
# # ╞═════╪═════╪═════╡
|
662
666
|
# # │ 1 ┆ 0 ┆ 0 │
|
663
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
|
664
667
|
# # │ 0 ┆ 1 ┆ 0 │
|
665
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
|
666
668
|
# # │ 0 ┆ 0 ┆ 1 │
|
667
669
|
# # └─────┴─────┴─────┘
|
668
|
-
def to_dummies
|
669
|
-
Utils.wrap_df(_s.to_dummies)
|
670
|
+
def to_dummies(separator: "_")
|
671
|
+
Utils.wrap_df(_s.to_dummies(separator))
|
670
672
|
end
|
671
673
|
|
672
674
|
# Count the unique values in a Series.
|
@@ -687,9 +689,7 @@ module Polars
|
|
687
689
|
# # │ i64 ┆ u32 │
|
688
690
|
# # ╞═════╪════════╡
|
689
691
|
# # │ 1 ┆ 1 │
|
690
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
|
691
692
|
# # │ 2 ┆ 2 │
|
692
|
-
# # ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
|
693
693
|
# # │ 3 ┆ 1 │
|
694
694
|
# # └─────┴────────┘
|
695
695
|
def value_counts(sort: false)
|
@@ -1285,8 +1285,12 @@ module Polars
|
|
1285
1285
|
# Expression or scalar value.
|
1286
1286
|
#
|
1287
1287
|
# @return [Integer]
|
1288
|
-
def search_sorted(element)
|
1289
|
-
|
1288
|
+
def search_sorted(element, side: "any")
|
1289
|
+
if element.is_a?(Integer) || element.is_a?(Float)
|
1290
|
+
return Polars.select(Polars.lit(self).search_sorted(element, side: side)).item
|
1291
|
+
end
|
1292
|
+
element = Series.new(element)
|
1293
|
+
Polars.select(Polars.lit(self).search_sorted(element, side: side)).to_series
|
1290
1294
|
end
|
1291
1295
|
|
1292
1296
|
# Get unique elements in series.
|
@@ -1500,7 +1504,7 @@ module Polars
|
|
1500
1504
|
# sets = Polars::Series.new("sets", [[1, 2, 3], [1, 2], [9, 10]])
|
1501
1505
|
# # =>
|
1502
1506
|
# # shape: (3,)
|
1503
|
-
# # Series: 'sets' [list]
|
1507
|
+
# # Series: 'sets' [list[i64]]
|
1504
1508
|
# # [
|
1505
1509
|
# # [1, 2, 3]
|
1506
1510
|
# # [1, 2]
|