polars-df 0.2.5 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/Cargo.lock +290 -137
  4. data/Cargo.toml +1 -1
  5. data/README.md +40 -2
  6. data/ext/polars/Cargo.toml +5 -4
  7. data/ext/polars/src/apply/dataframe.rs +6 -6
  8. data/ext/polars/src/apply/series.rs +10 -10
  9. data/ext/polars/src/batched_csv.rs +6 -4
  10. data/ext/polars/src/conversion.rs +56 -17
  11. data/ext/polars/src/dataframe.rs +65 -43
  12. data/ext/polars/src/error.rs +16 -8
  13. data/ext/polars/src/file.rs +5 -4
  14. data/ext/polars/src/lazy/apply.rs +1 -1
  15. data/ext/polars/src/lazy/dataframe.rs +12 -6
  16. data/ext/polars/src/lazy/dsl.rs +99 -45
  17. data/ext/polars/src/lazy/meta.rs +10 -9
  18. data/ext/polars/src/lib.rs +33 -29
  19. data/ext/polars/src/numo.rs +57 -0
  20. data/ext/polars/src/object.rs +2 -1
  21. data/ext/polars/src/series.rs +67 -53
  22. data/lib/polars/cat_expr.rb +0 -4
  23. data/lib/polars/cat_name_space.rb +0 -4
  24. data/lib/polars/convert.rb +0 -7
  25. data/lib/polars/data_frame.rb +165 -209
  26. data/lib/polars/data_types.rb +4 -0
  27. data/lib/polars/date_time_expr.rb +19 -151
  28. data/lib/polars/date_time_name_space.rb +17 -17
  29. data/lib/polars/expr.rb +68 -315
  30. data/lib/polars/group_by.rb +79 -51
  31. data/lib/polars/io.rb +1 -1
  32. data/lib/polars/lazy_frame.rb +1 -103
  33. data/lib/polars/lazy_functions.rb +0 -26
  34. data/lib/polars/lazy_group_by.rb +0 -8
  35. data/lib/polars/list_expr.rb +5 -27
  36. data/lib/polars/list_name_space.rb +5 -8
  37. data/lib/polars/plot.rb +109 -0
  38. data/lib/polars/series.rb +61 -19
  39. data/lib/polars/string_expr.rb +20 -76
  40. data/lib/polars/string_name_space.rb +5 -15
  41. data/lib/polars/struct_expr.rb +0 -2
  42. data/lib/polars/version.rb +1 -1
  43. data/lib/polars.rb +1 -0
  44. metadata +5 -3
@@ -1,6 +1,8 @@
1
1
  module Polars
2
2
  # Two-dimensional data structure representing data as a table with rows and columns.
3
3
  class DataFrame
4
+ include Plot
5
+
4
6
  # @private
5
7
  attr_accessor :_df
6
8
 
@@ -367,9 +369,7 @@ module Polars
367
369
  # # │ i64 ┆ i64 ┆ str │
368
370
  # # ╞═══════╪════════╪════════╡
369
371
  # # │ 1 ┆ 6 ┆ a │
370
- # # ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
371
372
  # # │ 2 ┆ 7 ┆ b │
372
- # # ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
373
373
  # # │ 3 ┆ 8 ┆ c │
374
374
  # # └───────┴────────┴────────┘
375
375
  def columns=(columns)
@@ -529,8 +529,12 @@ module Polars
529
529
  columns.include?(name)
530
530
  end
531
531
 
532
- # def each
533
- # end
532
+ # Returns an enumerator.
533
+ #
534
+ # @return [Object]
535
+ def each(&block)
536
+ get_columns.each(&block)
537
+ end
534
538
 
535
539
  # Returns subset of the DataFrame.
536
540
  #
@@ -602,10 +606,10 @@ module Polars
602
606
  return Slice.new(self).apply(item)
603
607
  end
604
608
 
605
- if Utils.is_str_sequence(item, allow_str: false)
609
+ if item.is_a?(Array) && item.all? { |v| Utils.strlike?(v) }
606
610
  # select multiple columns
607
611
  # df[["foo", "bar"]]
608
- return _from_rbdf(_df.select(item))
612
+ return _from_rbdf(_df.select(item.map(&:to_s)))
609
613
  end
610
614
 
611
615
  if Utils.is_int_sequence(item)
@@ -637,6 +641,7 @@ module Polars
637
641
  # Set item.
638
642
  #
639
643
  # @return [Object]
644
+ #
640
645
  # def []=(key, value)
641
646
  # if key.is_a?(String)
642
647
  # raise TypeError, "'DataFrame' object does not support 'Series' assignment by index. Use 'DataFrame.with_columns'"
@@ -645,6 +650,25 @@ module Polars
645
650
  # raise Todo
646
651
  # end
647
652
 
653
+
654
+ # Return the dataframe as a scalar.
655
+ #
656
+ # Equivalent to `df[0,0]`, with a check that the shape is (1,1).
657
+ #
658
+ # @return [Object]
659
+ #
660
+ # @example
661
+ # df = Polars::DataFrame.new({"a" => [1, 2, 3], "b" => [4, 5, 6]})
662
+ # result = df.select((Polars.col("a") * Polars.col("b")).sum)
663
+ # result.item
664
+ # # => 32
665
+ def item
666
+ if shape != [1, 1]
667
+ raise ArgumentError, "Can only call .item if the dataframe is of shape (1,1), dataframe is of shape #{shape}"
668
+ end
669
+ self[0, 0]
670
+ end
671
+
648
672
  # no to_arrow
649
673
 
650
674
  # Convert DataFrame to a hash mapping column name to values.
@@ -667,7 +691,8 @@ module Polars
667
691
  # @example
668
692
  # df = Polars::DataFrame.new({"foo" => [1, 2, 3], "bar" => [4, 5, 6]})
669
693
  # df.to_hashes
670
- # [{'foo': 1, 'bar': 4}, {'foo': 2, 'bar': 5}, {'foo': 3, 'bar': 6}]
694
+ # # =>
695
+ # # [{"foo"=>1, "bar"=>4}, {"foo"=>2, "bar"=>5}, {"foo"=>3, "bar"=>6}]
671
696
  def to_hashes
672
697
  rbdf = _df
673
698
  names = columns
@@ -677,8 +702,26 @@ module Polars
677
702
  end
678
703
  end
679
704
 
680
- # def to_numo
681
- # end
705
+ # Convert DataFrame to a 2D Numo array.
706
+ #
707
+ # This operation clones data.
708
+ #
709
+ # @return [Numo::NArray]
710
+ #
711
+ # @example
712
+ # df = Polars::DataFrame.new(
713
+ # {"foo" => [1, 2, 3], "bar" => [6, 7, 8], "ham" => ["a", "b", "c"]}
714
+ # )
715
+ # df.to_numo.class
716
+ # # => Numo::RObject
717
+ def to_numo
718
+ out = _df.to_numo
719
+ if out.nil?
720
+ Numo::NArray.vstack(width.times.map { |i| to_series(i).to_numo }).transpose
721
+ else
722
+ out
723
+ end
724
+ end
682
725
 
683
726
  # no to_pandas
684
727
 
@@ -1008,7 +1051,6 @@ module Polars
1008
1051
  # # │ str ┆ i64 ┆ i64 ┆ i64 │
1009
1052
  # # ╞════════╪══════════╪══════════╪══════════╡
1010
1053
  # # │ a ┆ 1 ┆ 2 ┆ 3 │
1011
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
1012
1054
  # # │ b ┆ 1 ┆ 2 ┆ 3 │
1013
1055
  # # └────────┴──────────┴──────────┴──────────┘
1014
1056
  #
@@ -1022,7 +1064,6 @@ module Polars
1022
1064
  # # │ i64 ┆ i64 ┆ i64 │
1023
1065
  # # ╞═════╪═════╪═════╡
1024
1066
  # # │ 1 ┆ 2 ┆ 3 │
1025
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1026
1067
  # # │ 1 ┆ 2 ┆ 3 │
1027
1068
  # # └─────┴─────┴─────┘
1028
1069
  #
@@ -1038,7 +1079,6 @@ module Polars
1038
1079
  # # │ str ┆ i64 ┆ i64 ┆ i64 │
1039
1080
  # # ╞═════╪═════╪═════╪═════╡
1040
1081
  # # │ a ┆ 1 ┆ 2 ┆ 3 │
1041
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1042
1082
  # # │ b ┆ 1 ┆ 2 ┆ 3 │
1043
1083
  # # └─────┴─────┴─────┴─────┘
1044
1084
  def transpose(include_header: false, header_name: "column", column_names: nil)
@@ -1080,9 +1120,7 @@ module Polars
1080
1120
  # # │ str ┆ i64 │
1081
1121
  # # ╞═════╪═════╡
1082
1122
  # # │ c ┆ 3 │
1083
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1084
1123
  # # │ b ┆ 2 │
1085
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1086
1124
  # # │ a ┆ 1 │
1087
1125
  # # └─────┴─────┘
1088
1126
  def reverse
@@ -1113,9 +1151,7 @@ module Polars
1113
1151
  # # │ i64 ┆ i64 ┆ str │
1114
1152
  # # ╞═══════╪═════╪═════╡
1115
1153
  # # │ 1 ┆ 6 ┆ a │
1116
- # # ├╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1117
1154
  # # │ 2 ┆ 7 ┆ b │
1118
- # # ├╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1119
1155
  # # │ 3 ┆ 8 ┆ c │
1120
1156
  # # └───────┴─────┴─────┘
1121
1157
  def rename(mapping)
@@ -1143,9 +1179,7 @@ module Polars
1143
1179
  # # │ i64 ┆ i64 ┆ i64 │
1144
1180
  # # ╞═════╪═════╪═════╡
1145
1181
  # # │ 1 ┆ 97 ┆ 4 │
1146
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1147
1182
  # # │ 2 ┆ 98 ┆ 5 │
1148
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1149
1183
  # # │ 3 ┆ 99 ┆ 6 │
1150
1184
  # # └─────┴─────┴─────┘
1151
1185
  #
@@ -1167,11 +1201,8 @@ module Polars
1167
1201
  # # │ i64 ┆ f64 ┆ bool ┆ f64 │
1168
1202
  # # ╞═════╪══════╪═══════╪══════╡
1169
1203
  # # │ 1 ┆ 0.5 ┆ true ┆ -2.5 │
1170
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
1171
1204
  # # │ 2 ┆ 4.0 ┆ true ┆ 15.0 │
1172
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
1173
1205
  # # │ 3 ┆ 10.0 ┆ false ┆ 20.5 │
1174
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
1175
1206
  # # │ 4 ┆ 13.0 ┆ true ┆ 0.0 │
1176
1207
  # # └─────┴──────┴───────┴──────┘
1177
1208
  def insert_at_idx(index, series)
@@ -1206,7 +1237,6 @@ module Polars
1206
1237
  # # │ i64 ┆ i64 ┆ str │
1207
1238
  # # ╞═════╪═════╪═════╡
1208
1239
  # # │ 1 ┆ 6 ┆ a │
1209
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1210
1240
  # # │ 2 ┆ 7 ┆ b │
1211
1241
  # # └─────┴─────┴─────┘
1212
1242
  #
@@ -1248,17 +1278,11 @@ module Polars
1248
1278
  # # │ str ┆ f64 ┆ f64 ┆ f64 ┆ str ┆ str │
1249
1279
  # # ╞════════════╪══════════╪══════════╪══════════╪══════╪══════╡
1250
1280
  # # │ count ┆ 3.0 ┆ 3.0 ┆ 3.0 ┆ 3 ┆ 3 │
1251
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
1252
1281
  # # │ null_count ┆ 0.0 ┆ 1.0 ┆ 0.0 ┆ 1 ┆ 1 │
1253
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
1254
1282
  # # │ mean ┆ 2.266667 ┆ 4.5 ┆ 0.666667 ┆ null ┆ null │
1255
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
1256
1283
  # # │ std ┆ 1.101514 ┆ 0.707107 ┆ 0.57735 ┆ null ┆ null │
1257
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
1258
1284
  # # │ min ┆ 1.0 ┆ 4.0 ┆ 0.0 ┆ b ┆ eur │
1259
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
1260
1285
  # # │ max ┆ 3.0 ┆ 5.0 ┆ 1.0 ┆ c ┆ usd │
1261
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
1262
1286
  # # │ median ┆ 2.8 ┆ 4.5 ┆ 1.0 ┆ null ┆ null │
1263
1287
  # # └────────────┴──────────┴──────────┴──────────┴──────┴──────┘
1264
1288
  def describe
@@ -1345,9 +1369,7 @@ module Polars
1345
1369
  # # │ i64 ┆ i64 ┆ str │
1346
1370
  # # ╞═══════╪═════╪═════╡
1347
1371
  # # │ 10 ┆ 6 ┆ a │
1348
- # # ├╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1349
1372
  # # │ 20 ┆ 7 ┆ b │
1350
- # # ├╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1351
1373
  # # │ 30 ┆ 8 ┆ c │
1352
1374
  # # └───────┴─────┴─────┘
1353
1375
  def replace_at_idx(index, series)
@@ -1386,9 +1408,7 @@ module Polars
1386
1408
  # # │ i64 ┆ f64 ┆ str │
1387
1409
  # # ╞═════╪═════╪═════╡
1388
1410
  # # │ 3 ┆ 8.0 ┆ c │
1389
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1390
1411
  # # │ 2 ┆ 7.0 ┆ b │
1391
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1392
1412
  # # │ 1 ┆ 6.0 ┆ a │
1393
1413
  # # └─────┴─────┴─────┘
1394
1414
  #
@@ -1405,9 +1425,7 @@ module Polars
1405
1425
  # # │ i64 ┆ f64 ┆ str │
1406
1426
  # # ╞═════╪═════╪═════╡
1407
1427
  # # │ 3 ┆ 8.0 ┆ c │
1408
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1409
1428
  # # │ 2 ┆ 7.0 ┆ b │
1410
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1411
1429
  # # │ 1 ┆ 6.0 ┆ a │
1412
1430
  # # └─────┴─────┴─────┘
1413
1431
  def sort(by, reverse: false, nulls_last: false)
@@ -1473,9 +1491,7 @@ module Polars
1473
1491
  # # │ i64 ┆ i64 │
1474
1492
  # # ╞═════╪═════╡
1475
1493
  # # │ 10 ┆ 4 │
1476
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1477
1494
  # # │ 20 ┆ 5 │
1478
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1479
1495
  # # │ 30 ┆ 6 │
1480
1496
  # # └─────┴─────┘
1481
1497
  def replace(column, new_col)
@@ -1510,7 +1526,6 @@ module Polars
1510
1526
  # # │ i64 ┆ f64 ┆ str │
1511
1527
  # # ╞═════╪═════╪═════╡
1512
1528
  # # │ 2 ┆ 7.0 ┆ b │
1513
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1514
1529
  # # │ 3 ┆ 8.0 ┆ c │
1515
1530
  # # └─────┴─────┴─────┘
1516
1531
  def slice(offset, length = nil)
@@ -1542,11 +1557,8 @@ module Polars
1542
1557
  # # │ i64 ┆ str │
1543
1558
  # # ╞═════╪═════╡
1544
1559
  # # │ 1 ┆ a │
1545
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1546
1560
  # # │ 2 ┆ b │
1547
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1548
1561
  # # │ 3 ┆ c │
1549
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1550
1562
  # # │ 4 ┆ d │
1551
1563
  # # └─────┴─────┘
1552
1564
  def limit(n = 5)
@@ -1577,9 +1589,7 @@ module Polars
1577
1589
  # # │ i64 ┆ i64 ┆ str │
1578
1590
  # # ╞═════╪═════╪═════╡
1579
1591
  # # │ 1 ┆ 6 ┆ a │
1580
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1581
1592
  # # │ 2 ┆ 7 ┆ b │
1582
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1583
1593
  # # │ 3 ┆ 8 ┆ c │
1584
1594
  # # └─────┴─────┴─────┘
1585
1595
  def head(n = 5)
@@ -1610,9 +1620,7 @@ module Polars
1610
1620
  # # │ i64 ┆ i64 ┆ str │
1611
1621
  # # ╞═════╪═════╪═════╡
1612
1622
  # # │ 3 ┆ 8 ┆ c │
1613
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1614
1623
  # # │ 4 ┆ 9 ┆ d │
1615
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1616
1624
  # # │ 5 ┆ 10 ┆ e │
1617
1625
  # # └─────┴─────┴─────┘
1618
1626
  def tail(n = 5)
@@ -1643,7 +1651,6 @@ module Polars
1643
1651
  # # │ i64 ┆ i64 ┆ str │
1644
1652
  # # ╞═════╪═════╪═════╡
1645
1653
  # # │ 1 ┆ 6 ┆ a │
1646
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1647
1654
  # # │ 3 ┆ 8 ┆ c │
1648
1655
  # # └─────┴─────┴─────┘
1649
1656
  def drop_nulls(subset: nil)
@@ -1685,11 +1692,8 @@ module Polars
1685
1692
  # # │ i64 ┆ i64 │
1686
1693
  # # ╞═════╪═════╡
1687
1694
  # # │ 1 ┆ 10 │
1688
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1689
1695
  # # │ 2 ┆ 20 │
1690
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1691
1696
  # # │ 3 ┆ 30 │
1692
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1693
1697
  # # │ 4 ┆ 40 │
1694
1698
  # # └─────┴─────┘
1695
1699
  def pipe(func, *args, **kwargs, &block)
@@ -1721,9 +1725,7 @@ module Polars
1721
1725
  # # │ u32 ┆ i64 ┆ i64 │
1722
1726
  # # ╞════════╪═════╪═════╡
1723
1727
  # # │ 0 ┆ 1 ┆ 2 │
1724
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1725
1728
  # # │ 1 ┆ 3 ┆ 4 │
1726
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
1727
1729
  # # │ 2 ┆ 5 ┆ 6 │
1728
1730
  # # └────────┴─────┴─────┘
1729
1731
  def with_row_count(name: "row_nr", offset: 0)
@@ -1758,18 +1760,13 @@ module Polars
1758
1760
  # # │ str ┆ i64 │
1759
1761
  # # ╞═════╪═════╡
1760
1762
  # # │ a ┆ 4 │
1761
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1762
1763
  # # │ b ┆ 11 │
1763
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
1764
1764
  # # │ c ┆ 6 │
1765
1765
  # # └─────┴─────┘
1766
1766
  def groupby(by, maintain_order: false)
1767
1767
  if !Utils.bool?(maintain_order)
1768
1768
  raise TypeError, "invalid input for groupby arg `maintain_order`: #{maintain_order}."
1769
1769
  end
1770
- if by.is_a?(String)
1771
- by = [by]
1772
- end
1773
1770
  GroupBy.new(
1774
1771
  _df,
1775
1772
  by,
@@ -1856,15 +1853,10 @@ module Polars
1856
1853
  # # │ datetime[μs] ┆ i64 ┆ i64 ┆ i64 │
1857
1854
  # # ╞═════════════════════╪═══════╪═══════╪═══════╡
1858
1855
  # # │ 2020-01-01 13:45:48 ┆ 3 ┆ 3 ┆ 3 │
1859
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
1860
1856
  # # │ 2020-01-01 16:42:13 ┆ 10 ┆ 3 ┆ 7 │
1861
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
1862
1857
  # # │ 2020-01-01 16:45:09 ┆ 15 ┆ 3 ┆ 7 │
1863
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
1864
1858
  # # │ 2020-01-02 18:12:48 ┆ 24 ┆ 3 ┆ 9 │
1865
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
1866
1859
  # # │ 2020-01-03 19:45:32 ┆ 11 ┆ 2 ┆ 9 │
1867
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
1868
1860
  # # │ 2020-01-08 23:16:43 ┆ 1 ┆ 1 ┆ 1 │
1869
1861
  # # └─────────────────────┴───────┴───────┴───────┘
1870
1862
  def groupby_rolling(
@@ -1961,17 +1953,11 @@ module Polars
1961
1953
  # # │ datetime[μs] ┆ i64 │
1962
1954
  # # ╞═════════════════════╪═════╡
1963
1955
  # # │ 2021-12-16 00:00:00 ┆ 0 │
1964
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
1965
1956
  # # │ 2021-12-16 00:30:00 ┆ 1 │
1966
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
1967
1957
  # # │ 2021-12-16 01:00:00 ┆ 2 │
1968
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
1969
1958
  # # │ 2021-12-16 01:30:00 ┆ 3 │
1970
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
1971
1959
  # # │ 2021-12-16 02:00:00 ┆ 4 │
1972
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
1973
1960
  # # │ 2021-12-16 02:30:00 ┆ 5 │
1974
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
1975
1961
  # # │ 2021-12-16 03:00:00 ┆ 6 │
1976
1962
  # # └─────────────────────┴─────┘
1977
1963
  #
@@ -1990,11 +1976,8 @@ module Polars
1990
1976
  # # │ datetime[μs] ┆ datetime[μs] ┆ datetime[μs] │
1991
1977
  # # ╞═════════════════════╪═════════════════════╪═════════════════════╡
1992
1978
  # # │ 2021-12-15 23:00:00 ┆ 2021-12-16 00:00:00 ┆ 2021-12-16 00:00:00 │
1993
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
1994
1979
  # # │ 2021-12-16 00:00:00 ┆ 2021-12-16 00:30:00 ┆ 2021-12-16 01:00:00 │
1995
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
1996
1980
  # # │ 2021-12-16 01:00:00 ┆ 2021-12-16 01:30:00 ┆ 2021-12-16 02:00:00 │
1997
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
1998
1981
  # # │ 2021-12-16 02:00:00 ┆ 2021-12-16 02:30:00 ┆ 2021-12-16 03:00:00 │
1999
1982
  # # └─────────────────────┴─────────────────────┴─────────────────────┘
2000
1983
  #
@@ -2010,11 +1993,8 @@ module Polars
2010
1993
  # # │ datetime[μs] ┆ datetime[μs] ┆ datetime[μs] ┆ u32 │
2011
1994
  # # ╞═════════════════════╪═════════════════════╪═════════════════════╪════════════╡
2012
1995
  # # │ 2021-12-15 23:00:00 ┆ 2021-12-16 00:00:00 ┆ 2021-12-15 23:00:00 ┆ 1 │
2013
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2014
1996
  # # │ 2021-12-16 00:00:00 ┆ 2021-12-16 01:00:00 ┆ 2021-12-16 00:00:00 ┆ 2 │
2015
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2016
1997
  # # │ 2021-12-16 01:00:00 ┆ 2021-12-16 02:00:00 ┆ 2021-12-16 01:00:00 ┆ 2 │
2017
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2018
1998
  # # │ 2021-12-16 02:00:00 ┆ 2021-12-16 03:00:00 ┆ 2021-12-16 02:00:00 ┆ 2 │
2019
1999
  # # └─────────────────────┴─────────────────────┴─────────────────────┴────────────┘
2020
2000
  #
@@ -2033,11 +2013,8 @@ module Polars
2033
2013
  # # │ datetime[μs] ┆ u32 ┆ list[datetime[μs]] │
2034
2014
  # # ╞═════════════════════╪════════════╪═════════════════════════════════════╡
2035
2015
  # # │ 2021-12-16 00:00:00 ┆ 2 ┆ [2021-12-16 00:00:00, 2021-12-16... │
2036
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
2037
2016
  # # │ 2021-12-16 01:00:00 ┆ 2 ┆ [2021-12-16 01:00:00, 2021-12-16... │
2038
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
2039
2017
  # # │ 2021-12-16 02:00:00 ┆ 2 ┆ [2021-12-16 02:00:00, 2021-12-16... │
2040
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
2041
2018
  # # │ 2021-12-16 03:00:00 ┆ 1 ┆ [2021-12-16 03:00:00] │
2042
2019
  # # └─────────────────────┴────────────┴─────────────────────────────────────┘
2043
2020
  #
@@ -2053,13 +2030,9 @@ module Polars
2053
2030
  # # │ datetime[μs] ┆ u32 │
2054
2031
  # # ╞═════════════════════╪════════════╡
2055
2032
  # # │ 2021-12-15 23:00:00 ┆ 1 │
2056
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2057
2033
  # # │ 2021-12-16 00:00:00 ┆ 3 │
2058
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2059
2034
  # # │ 2021-12-16 01:00:00 ┆ 3 │
2060
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2061
2035
  # # │ 2021-12-16 02:00:00 ┆ 3 │
2062
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2063
2036
  # # │ 2021-12-16 03:00:00 ┆ 1 │
2064
2037
  # # └─────────────────────┴────────────┘
2065
2038
  #
@@ -2089,17 +2062,11 @@ module Polars
2089
2062
  # # │ str ┆ datetime[μs] ┆ datetime[μs] ┆ datetime[μs] ┆ u32 │
2090
2063
  # # ╞════════╪═════════════════════╪═════════════════════╪═════════════════════╪════════════╡
2091
2064
  # # │ a ┆ 2021-12-15 23:00:00 ┆ 2021-12-16 00:00:00 ┆ 2021-12-15 23:00:00 ┆ 1 │
2092
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2093
2065
  # # │ a ┆ 2021-12-16 00:00:00 ┆ 2021-12-16 01:00:00 ┆ 2021-12-16 00:00:00 ┆ 3 │
2094
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2095
2066
  # # │ a ┆ 2021-12-16 01:00:00 ┆ 2021-12-16 02:00:00 ┆ 2021-12-16 01:00:00 ┆ 1 │
2096
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2097
2067
  # # │ a ┆ 2021-12-16 02:00:00 ┆ 2021-12-16 03:00:00 ┆ 2021-12-16 02:00:00 ┆ 2 │
2098
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2099
2068
  # # │ a ┆ 2021-12-16 03:00:00 ┆ 2021-12-16 04:00:00 ┆ 2021-12-16 03:00:00 ┆ 1 │
2100
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2101
2069
  # # │ b ┆ 2021-12-16 01:00:00 ┆ 2021-12-16 02:00:00 ┆ 2021-12-16 01:00:00 ┆ 2 │
2102
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
2103
2070
  # # │ b ┆ 2021-12-16 02:00:00 ┆ 2021-12-16 03:00:00 ┆ 2021-12-16 02:00:00 ┆ 1 │
2104
2071
  # # └────────┴─────────────────────┴─────────────────────┴─────────────────────┴────────────┘
2105
2072
  #
@@ -2125,9 +2092,7 @@ module Polars
2125
2092
  # # │ i64 ┆ i64 ┆ i64 ┆ list[str] │
2126
2093
  # # ╞═════════════════╪═════════════════╪═════╪═════════════════╡
2127
2094
  # # │ 0 ┆ 3 ┆ 0 ┆ ["A", "B", "B"] │
2128
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
2129
2095
  # # │ 2 ┆ 5 ┆ 2 ┆ ["B", "B", "C"] │
2130
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
2131
2096
  # # │ 4 ┆ 7 ┆ 4 ┆ ["C"] │
2132
2097
  # # └─────────────────┴─────────────────┴─────┴─────────────────┘
2133
2098
  def groupby_dynamic(
@@ -2213,17 +2178,11 @@ module Polars
2213
2178
  # # │ datetime[ns] ┆ str ┆ i64 │
2214
2179
  # # ╞═════════════════════╪════════╪════════╡
2215
2180
  # # │ 2021-02-01 00:00:00 ┆ A ┆ 0 │
2216
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
2217
2181
  # # │ 2021-03-01 00:00:00 ┆ A ┆ 0 │
2218
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
2219
2182
  # # │ 2021-04-01 00:00:00 ┆ A ┆ 0 │
2220
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
2221
2183
  # # │ 2021-05-01 00:00:00 ┆ A ┆ 2 │
2222
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
2223
2184
  # # │ 2021-04-01 00:00:00 ┆ B ┆ 1 │
2224
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
2225
2185
  # # │ 2021-05-01 00:00:00 ┆ B ┆ 1 │
2226
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
2227
2186
  # # │ 2021-06-01 00:00:00 ┆ B ┆ 3 │
2228
2187
  # # └─────────────────────┴────────┴────────┘
2229
2188
  def upsample(
@@ -2348,11 +2307,8 @@ module Polars
2348
2307
  # # │ datetime[ns] ┆ f64 ┆ i64 │
2349
2308
  # # ╞═════════════════════╪════════════╪══════╡
2350
2309
  # # │ 2016-05-12 00:00:00 ┆ 82.19 ┆ 4164 │
2351
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
2352
2310
  # # │ 2017-05-12 00:00:00 ┆ 82.66 ┆ 4411 │
2353
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
2354
2311
  # # │ 2018-05-12 00:00:00 ┆ 83.12 ┆ 4566 │
2355
- # # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
2356
2312
  # # │ 2019-05-12 00:00:00 ┆ 83.52 ┆ 4696 │
2357
2313
  # # └─────────────────────┴────────────┴──────┘
2358
2314
  def join_asof(
@@ -2427,7 +2383,6 @@ module Polars
2427
2383
  # # │ i64 ┆ f64 ┆ str ┆ str │
2428
2384
  # # ╞═════╪═════╪═════╪═══════╡
2429
2385
  # # │ 1 ┆ 6.0 ┆ a ┆ x │
2430
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
2431
2386
  # # │ 2 ┆ 7.0 ┆ b ┆ y │
2432
2387
  # # └─────┴─────┴─────┴───────┘
2433
2388
  #
@@ -2441,11 +2396,8 @@ module Polars
2441
2396
  # # │ i64 ┆ f64 ┆ str ┆ str │
2442
2397
  # # ╞══════╪══════╪═════╪═══════╡
2443
2398
  # # │ 1 ┆ 6.0 ┆ a ┆ x │
2444
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
2445
2399
  # # │ 2 ┆ 7.0 ┆ b ┆ y │
2446
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
2447
2400
  # # │ null ┆ null ┆ d ┆ z │
2448
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
2449
2401
  # # │ 3 ┆ 8.0 ┆ c ┆ null │
2450
2402
  # # └──────┴──────┴─────┴───────┘
2451
2403
  #
@@ -2459,9 +2411,7 @@ module Polars
2459
2411
  # # │ i64 ┆ f64 ┆ str ┆ str │
2460
2412
  # # ╞═════╪═════╪═════╪═══════╡
2461
2413
  # # │ 1 ┆ 6.0 ┆ a ┆ x │
2462
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
2463
2414
  # # │ 2 ┆ 7.0 ┆ b ┆ y │
2464
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
2465
2415
  # # │ 3 ┆ 8.0 ┆ c ┆ null │
2466
2416
  # # └─────┴─────┴─────┴───────┘
2467
2417
  #
@@ -2475,7 +2425,6 @@ module Polars
2475
2425
  # # │ i64 ┆ f64 ┆ str │
2476
2426
  # # ╞═════╪═════╪═════╡
2477
2427
  # # │ 1 ┆ 6.0 ┆ a │
2478
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
2479
2428
  # # │ 2 ┆ 7.0 ┆ b │
2480
2429
  # # └─────┴─────┴─────┘
2481
2430
  #
@@ -2546,9 +2495,7 @@ module Polars
2546
2495
  # # │ i64 ┆ i64 │
2547
2496
  # # ╞══════════╪══════════╡
2548
2497
  # # │ 2 ┆ -3 │
2549
- # # ├╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
2550
2498
  # # │ 4 ┆ 15 │
2551
- # # ├╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
2552
2499
  # # │ 6 ┆ 24 │
2553
2500
  # # └──────────┴──────────┘
2554
2501
  #
@@ -2562,9 +2509,7 @@ module Polars
2562
2509
  # # │ i64 │
2563
2510
  # # ╞═══════╡
2564
2511
  # # │ 1 │
2565
- # # ├╌╌╌╌╌╌╌┤
2566
2512
  # # │ 9 │
2567
- # # ├╌╌╌╌╌╌╌┤
2568
2513
  # # │ 14 │
2569
2514
  # # └───────┘
2570
2515
  def apply(return_dtype: nil, inference_size: 256, &f)
@@ -2599,9 +2544,7 @@ module Polars
2599
2544
  # # │ i64 ┆ i64 ┆ f64 │
2600
2545
  # # ╞═════╪═════╪═══════════╡
2601
2546
  # # │ 1 ┆ 2 ┆ 4.0 │
2602
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
2603
2547
  # # │ 3 ┆ 4 ┆ 16.0 │
2604
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
2605
2548
  # # │ 5 ┆ 6 ┆ 36.0 │
2606
2549
  # # └─────┴─────┴───────────┘
2607
2550
  #
@@ -2615,9 +2558,7 @@ module Polars
2615
2558
  # # │ f64 ┆ i64 │
2616
2559
  # # ╞══════╪═════╡
2617
2560
  # # │ 1.0 ┆ 2 │
2618
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌┤
2619
2561
  # # │ 9.0 ┆ 4 │
2620
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌┤
2621
2562
  # # │ 25.0 ┆ 6 │
2622
2563
  # # └──────┴─────┘
2623
2564
  def with_column(column)
@@ -2653,9 +2594,7 @@ module Polars
2653
2594
  # # │ i64 ┆ i64 ┆ str ┆ i64 │
2654
2595
  # # ╞═════╪═════╪═════╪═══════╡
2655
2596
  # # │ 1 ┆ 6 ┆ a ┆ 10 │
2656
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
2657
2597
  # # │ 2 ┆ 7 ┆ b ┆ 20 │
2658
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
2659
2598
  # # │ 3 ┆ 8 ┆ c ┆ 30 │
2660
2599
  # # └─────┴─────┴─────┴───────┘
2661
2600
  def hstack(columns, in_place: false)
@@ -2703,11 +2642,8 @@ module Polars
2703
2642
  # # │ i64 ┆ i64 ┆ str │
2704
2643
  # # ╞═════╪═════╪═════╡
2705
2644
  # # │ 1 ┆ 6 ┆ a │
2706
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
2707
2645
  # # │ 2 ┆ 7 ┆ b │
2708
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
2709
2646
  # # │ 3 ┆ 8 ┆ c │
2710
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
2711
2647
  # # │ 4 ┆ 9 ┆ d │
2712
2648
  # # └─────┴─────┴─────┘
2713
2649
  def vstack(df, in_place: false)
@@ -2753,15 +2689,10 @@ module Polars
2753
2689
  # # │ i64 ┆ i64 │
2754
2690
  # # ╞═════╪═════╡
2755
2691
  # # │ 1 ┆ 4 │
2756
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
2757
2692
  # # │ 2 ┆ 5 │
2758
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
2759
2693
  # # │ 3 ┆ 6 │
2760
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
2761
2694
  # # │ 10 ┆ 40 │
2762
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
2763
2695
  # # │ 20 ┆ 50 │
2764
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
2765
2696
  # # │ 30 ┆ 60 │
2766
2697
  # # └─────┴─────┘
2767
2698
  def extend(other)
@@ -2793,9 +2724,7 @@ module Polars
2793
2724
  # # │ i64 ┆ f64 │
2794
2725
  # # ╞═════╪═════╡
2795
2726
  # # │ 1 ┆ 6.0 │
2796
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
2797
2727
  # # │ 2 ┆ 7.0 │
2798
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
2799
2728
  # # │ 3 ┆ 8.0 │
2800
2729
  # # └─────┴─────┘
2801
2730
  def drop(columns)
@@ -2926,11 +2855,8 @@ module Polars
2926
2855
  # # │ i64 ┆ f64 │
2927
2856
  # # ╞═════╪══════╡
2928
2857
  # # │ 1 ┆ 0.5 │
2929
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2930
2858
  # # │ 2 ┆ 4.0 │
2931
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2932
2859
  # # │ 99 ┆ 99.0 │
2933
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2934
2860
  # # │ 4 ┆ 13.0 │
2935
2861
  # # └─────┴──────┘
2936
2862
  #
@@ -2944,11 +2870,8 @@ module Polars
2944
2870
  # # │ i64 ┆ f64 │
2945
2871
  # # ╞═════╪══════╡
2946
2872
  # # │ 1 ┆ 0.5 │
2947
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2948
2873
  # # │ 2 ┆ 4.0 │
2949
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2950
2874
  # # │ 2 ┆ 4.0 │
2951
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2952
2875
  # # │ 4 ┆ 13.0 │
2953
2876
  # # └─────┴──────┘
2954
2877
  #
@@ -2962,11 +2885,8 @@ module Polars
2962
2885
  # # │ i64 ┆ f64 │
2963
2886
  # # ╞═════╪══════╡
2964
2887
  # # │ 1 ┆ 0.5 │
2965
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2966
2888
  # # │ 2 ┆ 4.0 │
2967
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2968
2889
  # # │ 4 ┆ 13.0 │
2969
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2970
2890
  # # │ 4 ┆ 13.0 │
2971
2891
  # # └─────┴──────┘
2972
2892
  #
@@ -2980,11 +2900,8 @@ module Polars
2980
2900
  # # │ i64 ┆ f64 │
2981
2901
  # # ╞═════╪══════╡
2982
2902
  # # │ 1 ┆ 0.5 │
2983
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2984
2903
  # # │ 2 ┆ 4.0 │
2985
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2986
2904
  # # │ 0 ┆ 0.0 │
2987
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┤
2988
2905
  # # │ 4 ┆ 13.0 │
2989
2906
  # # └─────┴──────┘
2990
2907
  def fill_null(value = nil, strategy: nil, limit: nil, matches_supertype: true)
@@ -3023,11 +2940,8 @@ module Polars
3023
2940
  # # │ f64 ┆ f64 │
3024
2941
  # # ╞══════╪══════╡
3025
2942
  # # │ 1.5 ┆ 0.5 │
3026
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3027
2943
  # # │ 2.0 ┆ 4.0 │
3028
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3029
2944
  # # │ 99.0 ┆ 99.0 │
3030
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3031
2945
  # # │ 4.0 ┆ 13.0 │
3032
2946
  # # └──────┴──────┘
3033
2947
  def fill_nan(fill_value)
@@ -3057,19 +2971,12 @@ module Polars
3057
2971
  # # │ str ┆ i64 │
3058
2972
  # # ╞═════════╪═════════╡
3059
2973
  # # │ a ┆ 1 │
3060
- # # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
3061
2974
  # # │ a ┆ 2 │
3062
- # # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
3063
2975
  # # │ a ┆ 3 │
3064
- # # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
3065
2976
  # # │ b ┆ 4 │
3066
- # # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
3067
2977
  # # │ b ┆ 5 │
3068
- # # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
3069
2978
  # # │ c ┆ 6 │
3070
- # # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
3071
2979
  # # │ c ┆ 7 │
3072
- # # ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
3073
2980
  # # │ c ┆ 8 │
3074
2981
  # # └─────────┴─────────┘
3075
2982
  def explode(columns)
@@ -3111,7 +3018,6 @@ module Polars
3111
3018
  # # │ str ┆ i64 ┆ i64 ┆ i64 │
3112
3019
  # # ╞═════╪═════╪═════╪═════╡
3113
3020
  # # │ one ┆ 1 ┆ 2 ┆ 3 │
3114
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
3115
3021
  # # │ two ┆ 4 ┆ 5 ┆ 6 │
3116
3022
  # # └─────┴─────┴─────┴─────┘
3117
3023
  def pivot(
@@ -3120,7 +3026,8 @@ module Polars
3120
3026
  columns:,
3121
3027
  aggregate_fn: "first",
3122
3028
  maintain_order: true,
3123
- sort_columns: false
3029
+ sort_columns: false,
3030
+ separator: "_"
3124
3031
  )
3125
3032
  if values.is_a?(String)
3126
3033
  values = [values]
@@ -3162,7 +3069,8 @@ module Polars
3162
3069
  columns,
3163
3070
  aggregate_fn._rbexpr,
3164
3071
  maintain_order,
3165
- sort_columns
3072
+ sort_columns,
3073
+ separator
3166
3074
  )
3167
3075
  )
3168
3076
  end
@@ -3205,15 +3113,10 @@ module Polars
3205
3113
  # # │ str ┆ str ┆ i64 │
3206
3114
  # # ╞═════╪══════════╪═══════╡
3207
3115
  # # │ x ┆ b ┆ 1 │
3208
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
3209
3116
  # # │ y ┆ b ┆ 3 │
3210
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
3211
3117
  # # │ z ┆ b ┆ 5 │
3212
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
3213
3118
  # # │ x ┆ c ┆ 2 │
3214
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
3215
3119
  # # │ y ┆ c ┆ 4 │
3216
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
3217
3120
  # # │ z ┆ c ┆ 6 │
3218
3121
  # # └─────┴──────────┴───────┘
3219
3122
  def melt(id_vars: nil, value_vars: nil, variable_name: nil, value_name: nil)
@@ -3268,21 +3171,13 @@ module Polars
3268
3171
  # # │ str ┆ i64 │
3269
3172
  # # ╞══════╪══════╡
3270
3173
  # # │ A ┆ 0 │
3271
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3272
3174
  # # │ B ┆ 1 │
3273
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3274
3175
  # # │ C ┆ 2 │
3275
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3276
3176
  # # │ D ┆ 3 │
3277
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3278
3177
  # # │ ... ┆ ... │
3279
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3280
3178
  # # │ F ┆ 5 │
3281
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3282
3179
  # # │ G ┆ 6 │
3283
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3284
3180
  # # │ H ┆ 7 │
3285
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3286
3181
  # # │ I ┆ 8 │
3287
3182
  # # └──────┴──────┘
3288
3183
  #
@@ -3296,9 +3191,7 @@ module Polars
3296
3191
  # # │ str ┆ str ┆ str ┆ i64 ┆ i64 ┆ i64 │
3297
3192
  # # ╞════════╪════════╪════════╪════════╪════════╪════════╡
3298
3193
  # # │ A ┆ D ┆ G ┆ 0 ┆ 3 ┆ 6 │
3299
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
3300
3194
  # # │ B ┆ E ┆ H ┆ 1 ┆ 4 ┆ 7 │
3301
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
3302
3195
  # # │ C ┆ F ┆ I ┆ 2 ┆ 5 ┆ 8 │
3303
3196
  # # └────────┴────────┴────────┴────────┴────────┴────────┘
3304
3197
  #
@@ -3312,9 +3205,7 @@ module Polars
3312
3205
  # # │ str ┆ str ┆ str ┆ i64 ┆ i64 ┆ i64 │
3313
3206
  # # ╞════════╪════════╪════════╪════════╪════════╪════════╡
3314
3207
  # # │ A ┆ B ┆ C ┆ 0 ┆ 1 ┆ 2 │
3315
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
3316
3208
  # # │ D ┆ E ┆ F ┆ 3 ┆ 4 ┆ 5 │
3317
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
3318
3209
  # # │ G ┆ H ┆ I ┆ 6 ┆ 7 ┆ 8 │
3319
3210
  # # └────────┴────────┴────────┴────────┴────────┴────────┘
3320
3211
  def unstack(step:, how: "vertical", columns: nil, fill_values: nil)
@@ -3400,7 +3291,6 @@ module Polars
3400
3291
  # # │ str ┆ i64 ┆ str │
3401
3292
  # # ╞═════╪═════╪═════╡
3402
3293
  # # │ A ┆ 1 ┆ k │
3403
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
3404
3294
  # # │ A ┆ 2 ┆ l │
3405
3295
  # # └─────┴─────┴─────┘, shape: (2, 3)
3406
3296
  # # ┌─────┬─────┬─────┐
@@ -3409,7 +3299,6 @@ module Polars
3409
3299
  # # │ str ┆ i64 ┆ str │
3410
3300
  # # ╞═════╪═════╪═════╡
3411
3301
  # # │ B ┆ 2 ┆ m │
3412
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
3413
3302
  # # │ B ┆ 4 ┆ m │
3414
3303
  # # └─────┴─────┴─────┘, shape: (1, 3)
3415
3304
  # # ┌─────┬─────┬─────┐
@@ -3430,7 +3319,6 @@ module Polars
3430
3319
  # # │ str ┆ i64 ┆ str │
3431
3320
  # # ╞═════╪═════╪═════╡
3432
3321
  # # │ A ┆ 1 ┆ k │
3433
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
3434
3322
  # # │ A ┆ 2 ┆ l │
3435
3323
  # # └─────┴─────┴─────┘, "B"=>shape: (2, 3)
3436
3324
  # # ┌─────┬─────┬─────┐
@@ -3439,7 +3327,6 @@ module Polars
3439
3327
  # # │ str ┆ i64 ┆ str │
3440
3328
  # # ╞═════╪═════╪═════╡
3441
3329
  # # │ B ┆ 2 ┆ m │
3442
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
3443
3330
  # # │ B ┆ 4 ┆ m │
3444
3331
  # # └─────┴─────┴─────┘, "C"=>shape: (1, 3)
3445
3332
  # # ┌─────┬─────┬─────┐
@@ -3499,9 +3386,7 @@ module Polars
3499
3386
  # # │ i64 ┆ i64 ┆ str │
3500
3387
  # # ╞══════╪══════╪══════╡
3501
3388
  # # │ null ┆ null ┆ null │
3502
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3503
3389
  # # │ 1 ┆ 6 ┆ a │
3504
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3505
3390
  # # │ 2 ┆ 7 ┆ b │
3506
3391
  # # └──────┴──────┴──────┘
3507
3392
  #
@@ -3515,9 +3400,7 @@ module Polars
3515
3400
  # # │ i64 ┆ i64 ┆ str │
3516
3401
  # # ╞══════╪══════╪══════╡
3517
3402
  # # │ 2 ┆ 7 ┆ b │
3518
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3519
3403
  # # │ 3 ┆ 8 ┆ c │
3520
- # # ├╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
3521
3404
  # # │ null ┆ null ┆ null │
3522
3405
  # # └──────┴──────┴──────┘
3523
3406
  def shift(periods)
@@ -3550,9 +3433,7 @@ module Polars
3550
3433
  # # │ i64 ┆ i64 ┆ str │
3551
3434
  # # ╞═════╪═════╪═════╡
3552
3435
  # # │ 0 ┆ 0 ┆ 0 │
3553
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
3554
3436
  # # │ 1 ┆ 6 ┆ a │
3555
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
3556
3437
  # # │ 2 ┆ 7 ┆ b │
3557
3438
  # # └─────┴─────┴─────┘
3558
3439
  def shift_and_fill(periods, fill_value)
@@ -3642,9 +3523,7 @@ module Polars
3642
3523
  # # │ i64 │
3643
3524
  # # ╞═════╡
3644
3525
  # # │ 1 │
3645
- # # ├╌╌╌╌╌┤
3646
3526
  # # │ 2 │
3647
- # # ├╌╌╌╌╌┤
3648
3527
  # # │ 3 │
3649
3528
  # # └─────┘
3650
3529
  #
@@ -3658,9 +3537,7 @@ module Polars
3658
3537
  # # │ i64 ┆ i64 │
3659
3538
  # # ╞═════╪═════╡
3660
3539
  # # │ 1 ┆ 6 │
3661
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
3662
3540
  # # │ 2 ┆ 7 │
3663
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
3664
3541
  # # │ 3 ┆ 8 │
3665
3542
  # # └─────┴─────┘
3666
3543
  #
@@ -3674,9 +3551,7 @@ module Polars
3674
3551
  # # │ i64 │
3675
3552
  # # ╞═════╡
3676
3553
  # # │ 2 │
3677
- # # ├╌╌╌╌╌┤
3678
3554
  # # │ 3 │
3679
- # # ├╌╌╌╌╌┤
3680
3555
  # # │ 4 │
3681
3556
  # # └─────┘
3682
3557
  #
@@ -3690,9 +3565,7 @@ module Polars
3690
3565
  # # │ i64 ┆ i64 │
3691
3566
  # # ╞═════╪═════╡
3692
3567
  # # │ 2 ┆ 7 │
3693
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
3694
3568
  # # │ 3 ┆ 8 │
3695
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
3696
3569
  # # │ 4 ┆ 9 │
3697
3570
  # # └─────┴─────┘
3698
3571
  #
@@ -3706,9 +3579,7 @@ module Polars
3706
3579
  # # │ i64 │
3707
3580
  # # ╞═════════╡
3708
3581
  # # │ 0 │
3709
- # # ├╌╌╌╌╌╌╌╌╌┤
3710
3582
  # # │ 0 │
3711
- # # ├╌╌╌╌╌╌╌╌╌┤
3712
3583
  # # │ 10 │
3713
3584
  # # └─────────┘
3714
3585
  def select(exprs)
@@ -3750,11 +3621,8 @@ module Polars
3750
3621
  # # │ i64 ┆ f64 ┆ bool ┆ f64 ┆ f64 ┆ bool │
3751
3622
  # # ╞═════╪══════╪═══════╪══════╪══════╪═══════╡
3752
3623
  # # │ 1 ┆ 0.5 ┆ true ┆ 1.0 ┆ 0.25 ┆ false │
3753
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
3754
3624
  # # │ 2 ┆ 4.0 ┆ true ┆ 4.0 ┆ 2.0 ┆ false │
3755
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
3756
3625
  # # │ 3 ┆ 10.0 ┆ false ┆ 9.0 ┆ 5.0 ┆ true │
3757
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
3758
3626
  # # │ 4 ┆ 13.0 ┆ true ┆ 16.0 ┆ 6.5 ┆ false │
3759
3627
  # # └─────┴──────┴───────┴──────┴──────┴───────┘
3760
3628
  def with_columns(exprs)
@@ -4137,14 +4005,13 @@ module Polars
4137
4005
  # # │ u8 ┆ u8 ┆ u8 ┆ u8 ┆ u8 ┆ u8 │
4138
4006
  # # ╞═══════╪═══════╪═══════╪═══════╪═══════╪═══════╡
4139
4007
  # # │ 1 ┆ 0 ┆ 1 ┆ 0 ┆ 1 ┆ 0 │
4140
- # # ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
4141
4008
  # # │ 0 ┆ 1 ┆ 0 ┆ 1 ┆ 0 ┆ 1 │
4142
4009
  # # └───────┴───────┴───────┴───────┴───────┴───────┘
4143
- def to_dummies(columns: nil)
4010
+ def to_dummies(columns: nil, separator: "_")
4144
4011
  if columns.is_a?(String)
4145
4012
  columns = [columns]
4146
4013
  end
4147
- _from_rbdf(_df.to_dummies(columns))
4014
+ _from_rbdf(_df.to_dummies(columns, separator))
4148
4015
  end
4149
4016
 
4150
4017
  # Drop duplicate rows from this DataFrame.
@@ -4180,13 +4047,9 @@ module Polars
4180
4047
  # # │ i64 ┆ f64 ┆ bool │
4181
4048
  # # ╞═════╪═════╪═══════╡
4182
4049
  # # │ 1 ┆ 0.5 ┆ true │
4183
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
4184
4050
  # # │ 2 ┆ 1.0 ┆ true │
4185
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
4186
4051
  # # │ 3 ┆ 2.0 ┆ false │
4187
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
4188
4052
  # # │ 4 ┆ 3.0 ┆ true │
4189
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
4190
4053
  # # │ 5 ┆ 3.0 ┆ true │
4191
4054
  # # └─────┴─────┴───────┘
4192
4055
  def unique(maintain_order: true, subset: nil, keep: "first")
@@ -4320,7 +4183,6 @@ module Polars
4320
4183
  # # │ i64 ┆ i64 ┆ str │
4321
4184
  # # ╞═════╪═════╪═════╡
4322
4185
  # # │ 3 ┆ 8 ┆ c │
4323
- # # ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
4324
4186
  # # │ 2 ┆ 7 ┆ b │
4325
4187
  # # └─────┴─────┴─────┘
4326
4188
  def sample(
@@ -4440,6 +4302,10 @@ module Polars
4440
4302
  # Row index.
4441
4303
  # @param by_predicate [Object]
4442
4304
  # Select the row according to a given expression/predicate.
4305
+ # @param named [Boolean]
4306
+ # Return a hash instead of an array. The hash is a mapping of
4307
+ # column name to row value. This is more expensive than returning an
4308
+ # array, but allows for accessing values by column name.
4443
4309
  #
4444
4310
  # @return [Object]
4445
4311
  #
@@ -4462,25 +4328,44 @@ module Polars
4462
4328
  # df.row(2)
4463
4329
  # # => [3, 8, "c"]
4464
4330
  #
4331
+ # @example Get a hash instead with a mapping of column names to row values
4332
+ # df.row(2, named: true)
4333
+ # # => {"foo"=>3, "bar"=>8, "ham"=>"c"}
4334
+ #
4465
4335
  # @example Return the row that matches the given predicate
4466
4336
  # df.row(by_predicate: Polars.col("ham") == "b")
4467
4337
  # # => [2, 7, "b"]
4468
- def row(index = nil, by_predicate: nil)
4338
+ def row(index = nil, by_predicate: nil, named: false)
4469
4339
  if !index.nil? && !by_predicate.nil?
4470
4340
  raise ArgumentError, "Cannot set both 'index' and 'by_predicate'; mutually exclusive"
4471
4341
  elsif index.is_a?(Expr)
4472
4342
  raise TypeError, "Expressions should be passed to the 'by_predicate' param"
4473
- elsif index.is_a?(Integer)
4474
- _df.row_tuple(index)
4475
- elsif by_predicate.is_a?(Expr)
4343
+ end
4344
+
4345
+ if !index.nil?
4346
+ row = _df.row_tuple(index)
4347
+ if named
4348
+ columns.zip(row).to_h
4349
+ else
4350
+ row
4351
+ end
4352
+ elsif !by_predicate.nil?
4353
+ if !by_predicate.is_a?(Expr)
4354
+ raise TypeError, "Expected by_predicate to be an expression; found #{by_predicate.class.name}"
4355
+ end
4476
4356
  rows = filter(by_predicate).rows
4477
4357
  n_rows = rows.length
4478
4358
  if n_rows > 1
4479
4359
  raise TooManyRowsReturned, "Predicate #{by_predicate} returned #{n_rows} rows"
4480
4360
  elsif n_rows == 0
4481
- raise NoRowsReturned, "Predicate <{by_predicate!s}> returned no rows"
4361
+ raise NoRowsReturned, "Predicate #{by_predicate} returned no rows"
4362
+ end
4363
+ row = rows[0]
4364
+ if named
4365
+ columns.zip(row).to_h
4366
+ else
4367
+ row
4482
4368
  end
4483
- rows[0]
4484
4369
  else
4485
4370
  raise ArgumentError, "One of 'index' or 'by_predicate' must be set"
4486
4371
  end
@@ -4488,6 +4373,11 @@ module Polars
4488
4373
 
4489
4374
  # Convert columnar data to rows as Ruby arrays.
4490
4375
  #
4376
+ # @param named [Boolean]
4377
+ # Return hashes instead of arrays. The hashes are a mapping of
4378
+ # column name to row value. This is more expensive than returning an
4379
+ # array, but allows for accessing values by column name.
4380
+ #
4491
4381
  # @return [Array]
4492
4382
  #
4493
4383
  # @example
@@ -4499,8 +4389,79 @@ module Polars
4499
4389
  # )
4500
4390
  # df.rows
4501
4391
  # # => [[1, 2], [3, 4], [5, 6]]
4502
- def rows
4503
- _df.row_tuples
4392
+ # @example
4393
+ # df.rows(named: true)
4394
+ # # => [{"a"=>1, "b"=>2}, {"a"=>3, "b"=>4}, {"a"=>5, "b"=>6}]
4395
+ def rows(named: false)
4396
+ if named
4397
+ columns = columns()
4398
+ _df.row_tuples.map do |v|
4399
+ columns.zip(v).to_h
4400
+ end
4401
+ else
4402
+ _df.row_tuples
4403
+ end
4404
+ end
4405
+
4406
+ # Returns an iterator over the DataFrame of rows of python-native values.
4407
+ #
4408
+ # @param named [Boolean]
4409
+ # Return hashes instead of arrays. The hashes are a mapping of
4410
+ # column name to row value. This is more expensive than returning an
4411
+ # array, but allows for accessing values by column name.
4412
+ # @param buffer_size [Integer]
4413
+ # Determines the number of rows that are buffered internally while iterating
4414
+ # over the data; you should only modify this in very specific cases where the
4415
+ # default value is determined not to be a good fit to your access pattern, as
4416
+ # the speedup from using the buffer is significant (~2-4x). Setting this
4417
+ # value to zero disables row buffering.
4418
+ #
4419
+ # @return [Object]
4420
+ #
4421
+ # @example
4422
+ # df = Polars::DataFrame.new(
4423
+ # {
4424
+ # "a" => [1, 3, 5],
4425
+ # "b" => [2, 4, 6]
4426
+ # }
4427
+ # )
4428
+ # df.iter_rows.map { |row| row[0] }
4429
+ # # => [1, 3, 5]
4430
+ #
4431
+ # @example
4432
+ # df.iter_rows(named: true).map { |row| row["b"] }
4433
+ # # => [2, 4, 6]
4434
+ def iter_rows(named: false, buffer_size: 500, &block)
4435
+ return to_enum(:iter_rows, named: named, buffer_size: buffer_size) unless block_given?
4436
+
4437
+ # load into the local namespace for a modest performance boost in the hot loops
4438
+ columns = columns()
4439
+
4440
+ # note: buffering rows results in a 2-4x speedup over individual calls
4441
+ # to ".row(i)", so it should only be disabled in extremely specific cases.
4442
+ if buffer_size
4443
+ offset = 0
4444
+ while offset < height
4445
+ zerocopy_slice = slice(offset, buffer_size)
4446
+ rows_chunk = zerocopy_slice.rows(named: false)
4447
+ if named
4448
+ rows_chunk.each do |row|
4449
+ yield columns.zip(row).to_h
4450
+ end
4451
+ else
4452
+ rows_chunk.each(&block)
4453
+ end
4454
+ offset += buffer_size
4455
+ end
4456
+ elsif named
4457
+ height.times do |i|
4458
+ yield columns.zip(row(i)).to_h
4459
+ end
4460
+ else
4461
+ height.times do |i|
4462
+ yield row(i)
4463
+ end
4464
+ end
4504
4465
  end
4505
4466
 
4506
4467
  # Shrink DataFrame memory usage.
@@ -4534,7 +4495,6 @@ module Polars
4534
4495
  # # │ i64 ┆ i64 │
4535
4496
  # # ╞═════╪═════╡
4536
4497
  # # │ 1 ┆ 5 │
4537
- # # ├╌╌╌╌╌┼╌╌╌╌╌┤
4538
4498
  # # │ 3 ┆ 7 │
4539
4499
  # # └─────┴─────┘
4540
4500
  def take_every(n)
@@ -4602,11 +4562,8 @@ module Polars
4602
4562
  # # │ i64 ┆ i64 ┆ i64 │
4603
4563
  # # ╞═════╪══════╪═════╡
4604
4564
  # # │ 1 ┆ 6 ┆ 1 │
4605
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌┤
4606
4565
  # # │ 5 ┆ 7 ┆ 3 │
4607
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌┤
4608
4566
  # # │ 9 ┆ 9 ┆ 6 │
4609
- # # ├╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌┤
4610
4567
  # # │ 10 ┆ null ┆ 9 │
4611
4568
  # # └─────┴──────┴─────┘
4612
4569
  def interpolate
@@ -4687,7 +4644,6 @@ module Polars
4687
4644
  # # │ str ┆ i64 ┆ str ┆ bool ┆ list[i64] ┆ str │
4688
4645
  # # ╞════════╪═════╪═════╪══════╪═══════════╪═══════╡
4689
4646
  # # │ foo ┆ 1 ┆ a ┆ true ┆ [1, 2] ┆ baz │
4690
- # # ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
4691
4647
  # # │ bar ┆ 2 ┆ b ┆ null ┆ [3] ┆ womp │
4692
4648
  # # └────────┴─────┴─────┴──────┴───────────┴───────┘
4693
4649
  def unnest(names)