-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdoc.jl
1302 lines (1080 loc) · 46.4 KB
/
doc.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# custom help for byrow()
function Docs.getdoc(x::typeof(byrow), y)
if y == Union{}
return _get_doc_byrow("default")
elseif y == Tuple{typeof(sum)}
return _get_doc_byrow("sum")
elseif y == Tuple{typeof(mean)}
return _get_doc_byrow("mean")
elseif y == Tuple{typeof(all)}
return _get_doc_byrow("all")
elseif y == Tuple{typeof(any)}
return _get_doc_byrow("any")
elseif y == Tuple{typeof(count)}
return _get_doc_byrow("count")
elseif y == Tuple{typeof(prod)}
return _get_doc_byrow("prod")
elseif y == Tuple{typeof(isequal)}
return _get_doc_byrow("isequal")
elseif y == Tuple{typeof(isless)}
return _get_doc_byrow("isless")
elseif y == Tuple{typeof(in)}
return _get_doc_byrow("in")
elseif y == Tuple{typeof(findfirst)}
return _get_doc_byrow("findfirst")
elseif y == Tuple{typeof(findlast)}
return _get_doc_byrow("findlast")
elseif y == Tuple{typeof(select)}
return _get_doc_byrow("select")
elseif y == Tuple{typeof(fill!)}
return _get_doc_byrow("fill!")
elseif y == Tuple{typeof(fill)}
return _get_doc_byrow("fill")
elseif y == Tuple{typeof(coalesce)}
return _get_doc_byrow("coalesce")
elseif y == Tuple{typeof(maximum)}
return _get_doc_byrow("maximum")
elseif y == Tuple{typeof(minimum)}
return _get_doc_byrow("minimum")
elseif y == Tuple{typeof(argmax)}
return _get_doc_byrow("argmax")
elseif y == Tuple{typeof(argmin)}
return _get_doc_byrow("argmin")
elseif y == Tuple{typeof(issorted)}
return _get_doc_byrow("issorted")
elseif y == Tuple{typeof(join)}
return _get_doc_byrow("join")
elseif y == Tuple{typeof(hash)}
return _get_doc_byrow("hash")
elseif y == Tuple{typeof(nunique)}
return _get_doc_byrow("nunique")
elseif y == Tuple{typeof(mapreduce)}
return _get_doc_byrow("mapreduce")
elseif y == Tuple{typeof(var)}
return _get_doc_byrow("var")
elseif y == Tuple{typeof(std)}
return _get_doc_byrow("std")
elseif y == Tuple{typeof(cumsum!)}
return _get_doc_byrow("cumsum!")
elseif y == Tuple{typeof(cumsum)}
return _get_doc_byrow("cumsum")
elseif y == Tuple{typeof(cumprod!)}
return _get_doc_byrow("cumprod!")
elseif y == Tuple{typeof(cumprod)}
return _get_doc_byrow("cumprod")
elseif y == Tuple{typeof(cummax!)}
return _get_doc_byrow("cummax!")
elseif y == Tuple{typeof(cummax)}
return _get_doc_byrow("cummax")
elseif y == Tuple{typeof(cummin!)}
return _get_doc_byrow("cummin!")
elseif y == Tuple{typeof(cummin)}
return _get_doc_byrow("cummin")
elseif y == Tuple{typeof(sort!)}
return _get_doc_byrow("sort!")
elseif y == Tuple{typeof(sort)}
return _get_doc_byrow("sort")
elseif y == Tuple{typeof(stdze!)}
return _get_doc_byrow("stdze!")
elseif y == Tuple{typeof(stdze)}
return _get_doc_byrow("stdze")
else
return _get_doc_byrow("generic")
end
end
function _get_doc_byrow(fun; text = byrow_docs_text)
split_text = split(text, "@@@@")
loc = findfirst(==(fun), split_text)
Markdown.parse(split_text[loc+1])
end
byrow_docs_text = """
@@@@default@@@@
byrow(ds::AbstractDataset, fun, cols; ...)
Perform a row-wise operation specified by `fun` on selected columns `cols`. Generally,
`fun` can be any function that returns a scalar value for each row.
> User can pass a type as `fun` when `cols` is referring to a single column. In this case, `byrow` simply converts the selected column to vector of type `fun`.
`byrow` is fine tuned for the following operations. To get extra help for each of them search help for `byrow(fun)`, e.g. `?byrow(sum)`;
# Reduction operations
- `all`
- `any`
- `argmax`
- `argmin`
- `coalesce`
- `count`
- `findfirst`
- `findlast`
- `hash`
- `in`
- `isequal`
- `isless`
- `issorted`
- `join`
- `mapreduce`
- `maximum`
- `mean`
- `minimum`
- `nunique`
- `prod`
- `select`
- `std`
- `sum`
- `var`
# Special operations
- `cummax`
- `cummax!`
- `cummin`
- `cummin!`
- `cumprod`
- `cumprod!`
- `cumsum`
- `cumsum!`
- `fill`
- `fill!`
- `sort`
- `sort!`
- `stdze`
- `stdze!`
@@@@sum@@@@
byrow(ds::AbstractDataset, sum, cols = names(ds, Number); [by = identity, threads])
Sum results of calling function `by` on each element of each row of `ds`. If `cols` is not specified, `byrow`
computes sum for all numeric columns in `ds`.
Passing `threads = false` disables multithreaded computations.
Missing values are removed from the calculation. When all values in a row are missing, it returns `missing`.
## Example
```jldoctest
julia> ds = Dataset(x = [1,2,3], y = [2.0, 1.5, 4.0])
3×2 Dataset
Row │ x y
│ identity identity
│ Int64? Float64?
─────┼────────────────────
1 │ 1 2.0
2 │ 2 1.5
3 │ 3 4.0
julia> byrow(ds, sum, :)
3-element Vector{Float64}:
3.0
3.5
7.0
```
@@@@mean@@@@
byrow(ds::AbstractDataset, mean, cols = names(ds, Number); [by = identity, threads])
Compute mean of the results of calling function `by` on each element of each row of `ds`. If `cols` is not specified, `byrow`
computes mean for all numeric columns in `ds`.
Passing `threads = false` disables multithreaded computations.
Missing values are removed from the calculation. When all values in a row are missing, it returns `missing`.
## Example
```jldoctest
julia> ds = Dataset(x = [1,2,3], y = [2.0, 1.5, 4.0])
3×2 Dataset
Row │ x y
│ identity identity
│ Int64? Float64?
─────┼────────────────────
1 │ 1 2.0
2 │ 2 1.5
3 │ 3 4.0
julia> byrow(ds, mean, :)
3-element Vector{Float64}:
1.5
1.75
3.5
```
@@@@all@@@@
byrow(ds::AbstractDataset, all, cols = :; [by = isequal(true), threads, mapformats = false])
Test whether all elements in each row in selected columns are `true`, when `by` is passed, determine whether predicate `by` returns `true` for all elements in the row.
By default, `byrow` uses the actual values for test the elements, however, passing `mapformats = true`
change this to the formatted values.
Each columns in `cols` may have its own `by`. This may be achieved by passing a vector of predicates to `by`.
Passing `threads = false` disables multithreaded computations.
See [`filter`](@ref), [`filter!`](@ref), [`delete`](@ref), [`delete!`](@ref)
## Example
```jldoctest
julia> ds = Dataset(x = [1,2,3], y = [2.0, 1.5, 4.0])
3×2 Dataset
Row │ x y
│ identity identity
│ Int64? Float64?
─────┼────────────────────
1 │ 1 2.0
2 │ 2 1.5
3 │ 3 4.0
julia> byrow(ds, all, :, by = [==(2), >(1)])
3-element Vector{Bool}:
0
1
0
```
@@@@any@@@@
byrow(ds::AbstractDataset, any, cols = :; [by = isequal(true), threads, mapformats = false])
Test whether any elements in each row in selected columns is `true`, when `by` is passed, determine whether predicate `by` returns `true` for any elements in the row.
By default, `byrow` uses the actual values for test the elements, however, passing `mapformats = true`
change this to the formatted values.
Each columns in `cols` may have its own `by`. This may be achieved by passing a vector of predicates to `by`.
Passing `threads = false` disables multithreaded computations.
See [`filter`](@ref), [`filter!`](@ref), [`delete`](@ref), [`delete!`](@ref)
## Example
```jldoctest
julia> ds = Dataset(x = [1,2,3], y = [2.0, 1.5, 4.0])
3×2 Dataset
Row │ x y
│ identity identity
│ Int64? Float64?
─────┼────────────────────
1 │ 1 2.0
2 │ 2 1.5
3 │ 3 4.0
julia> byrow(ds, any, :, by = [==(2), >(1)])
3-element Vector{Bool}:
1
1
1
```
@@@@count@@@@
byrow(ds::AbstractDataset, count, cols = :; [by = isequal(true), threads])
Count the number of elements in each row for selected columns which the function `by` returns `true`.
Passing `threads = false` disables multithreaded computations.
## Example
```jldoctest
julia> julia> ds = Dataset(x = [1,2,3], y = [2, 6, 5])
3×2 Dataset
Row │ x y
│ identity identity
│ Int64? Int64?
─────┼────────────────────
1 │ 1 2
2 │ 2 6
3 │ 3 5
julia> byrow(ds, count, :, by = isodd)
3-element Vector{Int32}:
1
0
2
```
@@@@prod@@@@
byrow(ds::AbstractDataset, prod, cols = names(ds, Number); [by = identity, threads])
Return the product of the results of calling function `by` on each element of each row of `ds`. If `cols` is not specified, `byrow`
computes product for all numeric columns in `ds`.
Passing `threads = false` disables multithreaded computations.
Missing values are removed from the calculation. When all values in a row are missing, it returns `missing`.
## Example
```jldoctest
julia> ds = Dataset(x = [1,2,3], y = [2.0, 1.5, 4.0])
3×2 Dataset
Row │ x y
│ identity identity
│ Int64? Float64?
─────┼────────────────────
1 │ 1 2.0
2 │ 2 1.5
3 │ 3 4.0
julia> byrow(ds, prod, :)
3-element Vector{Union{Missing, Float64}}:
2.0
3.0
12.0
```
@@@@isequal@@@@
byrow(ds::AbstractDataset, isequal, cols; [with = nothing, threads])
Returns a boolean vector which is `true` if all values in the corresponding row are equal (using `isequal`).
Optionally, a vector of values can be passed view the `with` keyword argument to compare values in selected
columns with the passed vector.
Passing `threads = false` disables multithreaded computations.
See [`byrow(isless)`](@ref), [`byrow(in)`](@ref), [`byrow(issorted)`](@ref)
## Examples
```jldoctest
julia> ds = Dataset(x1 = [1,2,3,1,2,3], x2 = [1,2,1,2,1,2])
6×2 Dataset
Row │ x1 x2
│ identity identity
│ Int64? Int64?
─────┼────────────────────
1 │ 1 1
2 │ 2 2
3 │ 3 1
4 │ 1 2
5 │ 2 1
6 │ 3 2
julia> byrow(ds, isequal, [1,2])
6-element Vector{Bool}:
1
1
0
0
0
0
julia> byrow(ds, isequal, [1,2], with = [2,2,2,3,3,3])
6-element Vector{Bool}:
0
1
0
0
0
0
```
@@@@isless@@@@
byrow(ds::AbstractDataset, isless, cols, [with, threads, rev = false, lt = isless])
Return a boolean vector which is true if all values in corresponding row for selected `cols` are less than value given by the `with` keyword argument. A vector, or a column name can be passed via `with`.
Passing `rev = true` returns true if all values are greater than passed values via `with`.
By default, the comparison is done via `isless` function, however, user may change it by passing a function via the `lt` keyword argument. The function passed to `lt` must accept two arguments where it takes its first argument from `cols` and its second argument from `with`. However, if `rev = true` the function passed as `lt` will take its first argument from `with` and its second argument from `cols`. The function passed as `lt` must return `true` or `false`.
Passing `threads = false` disables multithreaded computations.
See [`byrow(isequal)`](@ref), [`byrow(in)`](@ref), [`byrow(issorted)`](@ref)
## Examples
```jldoctest
julia> ds = Dataset(x1 = [1,2,3,1,2,3], x2 = [1,2,1,2,1,2], x3 = 6:-1:1)
6×3 Dataset
Row │ x1 x2 x3
│ identity identity identity
│ Int64? Int64? Int64?
─────┼──────────────────────────────
1 │ 1 1 6
2 │ 2 2 5
3 │ 3 1 4
4 │ 1 2 3
5 │ 2 1 2
6 │ 3 2 1
julia> byrow(ds, isless, [1,2], with = :x3)
6-element Vector{Bool}:
1
1
1
1
0
0
julia> byrow(ds, isless, 1:2, with = :x3, lt = (x,y) -> isless(x^2, y))
6-element Vector{Bool}:
1
1
0
0
0
0
julia> ds = Dataset(x1 = [1,2,3,1,2,3], x2 = [1,2,1,2,1,2],
x3 = [(1,2), (2,3), (1,2), (4,5), (1,2), (1,2)])
6×3 Dataset
Row │ x1 x2 x3
│ identity identity identity
│ Int64? Int64? Tuple…?
─────┼──────────────────────────────
1 │ 1 1 (1, 2)
2 │ 2 2 (2, 3)
3 │ 3 1 (1, 2)
4 │ 1 2 (4, 5)
5 │ 2 1 (1, 2)
6 │ 3 2 (1, 2)
julia> byrow(ds, isless, 1:2, with = :x3, lt = in)
6-element Vector{Bool}:
1
1
0
0
1
0
```
@@@@in@@@@
byrow(ds::AbstractDataset, in, cols; [item, threads, eq = isequal])
Return a boolean vector which its elements are true if in a row the value of `item` is equal to any values from `cols`. The equality is checked via the function passed as `eq`. User can pass a vector of values or a column name to `item`.
The function passed as `eq` must accept two arguments where it takes its first argument from `item` and its second argument from `cols`. The function passed as `eq` must return `true` or `false`.
Passing `threads = false` disables multithreaded computations.
See [`byrow(isequal)`](@ref), [`byrow(isless)`](@ref), [`byrow(issorted)`](@ref)
## Examples
```jldoctest
julia> ds = Dataset(x1 = [1,2,3,1,2,3], x2 = [1,2,1,2,1,2], x3 = 6:-1:1)
6×3 Dataset
Row │ x1 x2 x3
│ identity identity identity
│ Int64? Int64? Int64?
─────┼──────────────────────────────
1 │ 1 1 6
2 │ 2 2 5
3 │ 3 1 4
4 │ 1 2 3
5 │ 2 1 2
6 │ 3 2 1
julia> byrow(ds, in, r"x", item = [1,2,3,4,5,6])
6-element Vector{Bool}:
1
1
1
0
0
0
julia> byrow(ds, in, [2,3], item = :x1, eq = isless)
6-element Vector{Bool}:
1
1
1
1
0
0
julia> byrow(ds, in, r"x", item = [5,4,5,4,5,4], eq = (x,y) -> x+y == 11)
6-element Vector{Bool}:
1
0
0
0
0
0
```
@@@@findfirst@@@@
byrow(ds::AbstractDataset, findfirst, cols; [by = identity, item = nothing, eq = isequal, threads])
Return the column name of the first `true` value in `cols` or for which `by` returns `true`. If no such value is found, it returns `missing`. User can pass a vector of values or a column name to `item` to find the column name of the first time that the value of `item` is equal to the value of the column. User may use a customised function for checking the equlity of `item` and `columns` by passing it to the `eq` keyword argument. The function passed as `eq` must be a binary function where its first argument is from `item` and its second argument is from `col`.
Passing `threads = false` disables multithreaded computations.
See [`byrow(findlast)`](@ref), [`byrow(select)`](@ref)
# Examples
```jldoctest
julia> ds = Dataset(g = [1, 1, 1, 2, 2],
x1_int = [0, 0, 1, missing, 2],
x2_int = [3, 2, 1, 3, -2],
x1_float = [1.2, missing, -1.0, 2.3, 10],
x2_float = [missing, missing, 3.0, missing, missing],
x3_float = [missing, missing, -1.4, 3.0, -100.0])
5×6 Dataset
Row │ g x1_int x2_int x1_float x2_float x3_float
│ identity identity identity identity identity identity
│ Int64? Int64? Int64? Float64? Float64? Float64?
─────┼───────────────────────────────────────────────────────────────
1 │ 1 0 3 1.2 missing missing
2 │ 1 0 2 missing missing missing
3 │ 1 1 1 -1.0 3.0 -1.4
4 │ 2 missing 3 2.3 missing 3.0
5 │ 2 2 -2 10.0 missing -100.0
julia> byrow(ds, findfirst, :, by = ismissing)
5-element PooledArrays.PooledVector{Union{Missing, Symbol}, UInt32, Vector{UInt32}}:
:x2_float
:x1_float
missing
:x1_int
:x2_float
julia> byrow(ds, findfirst, 1:3, item = [1,1,1,1,1])
5-element PooledArrays.PooledVector{Union{Missing, Symbol}, UInt32, Vector{UInt32}}:
:g
:g
:g
missing
missing
julia> ds = Dataset(x1 = [1,2,2], x2 = [5,6,7], x3 = [8,9,10])
3×3 Dataset
Row │ x1 x2 x3
│ identity identity identity
│ Int64? Int64? Int64?
─────┼──────────────────────────────
1 │ 1 5 8
2 │ 2 6 9
3 │ 2 7 10
julia> byrow(ds, select, :, with = byrow(ds, findfirst, :, by = isodd))
3-element Vector{Union{Missing, Int64}}:
1
9
7
```
@@@@findlast@@@@
byrow(ds::AbstractDataset, findlast, cols; [by = identity, item = nothing, eq = isequal, threads])
Return the column name of the last `true` value in `cols` or for which `by` returns `true`. If no such value is found, it returns `missing`. User can pass a vector of values or a column name to `item` to find the column name of the last time that the value of `item` is equal to the value of the column. User may use a customised function for checking the equlity of `item` and `columns` by passing it to the `eq` keyword argument. The function passed as `eq` must be a binary function where its first argument is from `item` and its second argument is from `col`.
Passing `threads = false` disables multithreaded computations.
See [`byrow(findfirst)`](@ref), [`byrow(select)`](@ref)
# Examples
```jldoctest
julia> ds = Dataset(g = [1, 1, 1, 2, 2],
x1_int = [0, 0, 1, missing, 2],
x2_int = [3, 2, 1, 3, -2],
x1_float = [1.2, missing, -1.0, 2.3, 10],
x2_float = [missing, missing, 3.0, missing, missing],
x3_float = [missing, missing, -1.4, 3.0, -100.0])
5×6 Dataset
Row │ g x1_int x2_int x1_float x2_float x3_float
│ identity identity identity identity identity identity
│ Int64? Int64? Int64? Float64? Float64? Float64?
─────┼───────────────────────────────────────────────────────────────
1 │ 1 0 3 1.2 missing missing
2 │ 1 0 2 missing missing missing
3 │ 1 1 1 -1.0 3.0 -1.4
4 │ 2 missing 3 2.3 missing 3.0
5 │ 2 2 -2 10.0 missing -100.0
julia> byrow(ds, findlast, :, by = ismissing)
5-element PooledArrays.PooledVector{Union{Missing, Symbol}, UInt32, Vector{UInt32}}:
:x3_float
:x3_float
missing
:x2_float
:x2_float
julia> byrow(ds, findlast, 1:3, item = [1,1,1,1,1])
5-element PooledArrays.PooledVector{Union{Missing, Symbol}, UInt32, Vector{UInt32}}:
:g
:g
:x2_int
missing
missing
julia> ds = Dataset(x1 = [1,2,2], x2 = [5,6,7], x3 = [8,9,10])
3×3 Dataset
Row │ x1 x2 x3
│ identity identity identity
│ Int64? Int64? Int64?
─────┼──────────────────────────────
1 │ 1 5 8
2 │ 2 6 9
3 │ 2 7 10
julia> byrow(ds, select, :, with = byrow(ds, findlast, :, by = isodd))
3-element Vector{Union{Missing, Int64}}:
5
9
7
```
@@@@select@@@@
byrow(ds::AbstractDataset, select, cols; [with, threads])
Select value of `with` among `cols`. The `with` must be a vector of column names(`Symbol` or `String`) or column index (relative to column position in `cols`) or a column name which contains this information.
For heterogeneous column types, `byrow` use `promote_type` for the output. If the column select doesn't exist among `cols`, `byrow` returns `missing`.
Passing `threads = false` disables multithreaded computations.
See [`byrow(findfirst)`](@ref), [`byrow(findlast)`](@ref)
# Examples
```jldoctest
julia> ds = Dataset(x1 = [1,2,3,4],
x2 = [1.5,6.5,3.4,2.4],
x3 = [true, false, true, false],
y1 = ["x2", "x1", missing, "x2"],
y2 = [:x2, :x1, missing, :x2],
y3 = [3,1,1,2])
4×6 Dataset
Row │ x1 x2 x3 y1 y2 y3
│ identity identity identity identity identity identity
│ Int64? Float64? Bool? String? Symbol? Int64?
─────┼────────────────────────────────────────────────────────────
1 │ 1 1.5 true x2 x2 3
2 │ 2 6.5 false x1 x1 1
3 │ 3 3.4 true missing missing 1
4 │ 4 2.4 false x2 x2 2
julia> byrow(ds, select, 1:2, with = :y1)
4-element Vector{Union{Missing, Float64}}:
1.5
2.0
missing
2.4
julia> byrow(ds, select, [2,1,3], with = :y3)
4-element Vector{Union{Missing, Float64}}:
1.0
6.5
3.4
4.0
julia> byrow(ds, select, [2,1,3], with = [3,1,1,2])
4-element Vector{Union{Missing, Float64}}:
1.0
6.5
3.4
4.0
julia> ds = Dataset(x1 = [1,2,2], x2 = [5,6,7], x3 = [8,9,10])
3×3 Dataset
Row │ x1 x2 x3
│ identity identity identity
│ Int64? Int64? Int64?
─────┼──────────────────────────────
1 │ 1 5 8
2 │ 2 6 9
3 │ 2 7 10
julia> byrow(ds, select, :, with = byrow(ds, findfirst, :, by = isodd))
3-element Vector{Union{Missing, Int64}}:
1
9
7
```
@@@@fill!@@@@
byrow(ds::AbstractDataset, fill!, cols; [with, by = ismissing, rolling = false, threads])
Fill missing (default behaviour) values in `cols` with values from `with`. User can pass a vector of values or a column name to `with`. `byrow` fills the values in-place, so the type of `cols` and `with` must match. By default, `byrow` fills only missing values in `cols`, but, user can pass any function to `by` which `byrow` fills only the values that returns `true` when `by` is called on them.
When `rolling = true`, `byrow` uses `with` to fill the missing values in the first column among `cols` and replace `with` with the updated values in the first column and uses these values to fill the missing values in the second column among `cols` and replace `with` with the updated values in the second column, and continues this process.
Passing `threads = false` disables multithreaded computations.
`fill!` is a special `byrow` operations, because it changes the input data set rather than producing a vector.
See [`byrow(fill)`](@ref)
# Examples
```jldoctest
julia> ds = Dataset(x = [1,missing,3], y = [missing,2, 3])
3×2 Dataset
Row │ x y
│ identity identity
│ Int64? Int64?
─────┼────────────────────
1 │ 1 missing
2 │ missing 2
3 │ 3 3
julia> byrow(ds, fill!, :, with = 1:3)
3×2 Dataset
Row │ x y
│ identity identity
│ Int64? Int64?
─────┼────────────────────
1 │ 1 1
2 │ 2 2
3 │ 3 3
julia> ds = Dataset(x = [1,0,3], y = [0,2,3])
3×2 Dataset
Row │ x y
│ identity identity
│ Int64? Int64?
─────┼────────────────────
1 │ 1 0
2 │ 0 2
3 │ 3 3
julia> byrow(ds, fill!, :, with = 1:3, by = isequal(0))
3×2 Dataset
Row │ x y
│ identity identity
│ Int64? Int64?
─────┼────────────────────
1 │ 1 1
2 │ 2 2
3 │ 3 3
julia> ds = Dataset(x = [2,0,3], y = [0,2,3], z = [5,0,0])
3×3 Dataset
Row │ x y z
│ identity identity identity
│ Int64? Int64? Int64?
─────┼──────────────────────────────
1 │ 2 0 5
2 │ 0 2 0
3 │ 3 3 0
julia> byrow(ds, fill!, :, with = [missing, missing, missing], by = isequal(0), rolling = true)
3×3 Dataset
Row │ x y z
│ identity identity identity
│ Int64? Int64? Int64?
─────┼──────────────────────────────
1 │ 2 2 5
2 │ missing 2 2
3 │ 3 3 3
```
@@@@fill@@@@
byrow(ds::AbstractDataset, fill, cols; [with, by = ismissing, rolling = false, threads])
Variant of `byrow(fill!)` which passes a copy of `ds` and leaves `ds` unchanged.
See [`byrow(fill!)`](@ref)
@@@@coalesce@@@@
byrow(ds::AbstractDataset, coalesce, cols; [threads])
Return the first value in each row of `cols` which is not equal to `missing`, if any. Otherwise return `missing`.
Passing `threads = false` disables multithreaded computations.
See [`byrow(select)`](@ref), [`byrow(findfirst)`](@ref), [`byrow(findlast)`](@ref)
# Examples
```jldoctest
julia> ds = Dataset(x = [1,missing, missing], y = [missing, missing, 3], z = [5, missing, missing])
3×3 Dataset
Row │ x y z
│ identity identity identity
│ Int64? Int64? Int64?
─────┼──────────────────────────────
1 │ 1 missing 5
2 │ missing missing missing
3 │ missing 3 missing
julia> byrow(ds, coalesce, :)
3-element Vector{Union{Missing, Int64}}:
1
missing
3
julia> byrow(ds, coalesce, [:z, :y, :x])
3-element Vector{Union{Missing, Int64}}:
5
missing
3
```
@@@@maximum@@@@
byrow(ds::AbstractDataset, maximum, cols; [by = identity, threads])
Return the largest result of calling function `by` on each values in each row (of selected columns). If `cols` is not specified, `byrow`
returns maximum for all numeric columns in `ds`.
Missing values are removed from the calculation. When all values in a row are missing, it returns `missing`.
Passing `threads = false` disables multithreaded computations.
See [`byrow(minimum)`](@ref), [`byrow(argmax)`](@ref), [`byrow(argmin)`](@ref)
# Examples
```jldoctest
julia> ds = Dataset(x=[1,2,3], y=[1.3,-2.4,5.5], z=[missing, 4,1])
3×3 Dataset
Row │ x y z
│ identity identity identity
│ Int64? Float64? Int64?
─────┼──────────────────────────────
1 │ 1 1.3 missing
2 │ 2 -2.4 4
3 │ 3 5.5 1
julia> byrow(ds, maximum)
3-element Vector{Union{Missing, Float64}}:
1.3
4.0
5.5
julia> byrow(ds, maximum, [1,3])
3-element Vector{Union{Missing, Int64}}:
1
4
3
```
@@@@minimum@@@@
byrow(ds::AbstractDataset, minimum, cols; [by = identity, threads])
Return the smallest result of calling function `by` on each values in each row (of selected columns). If `cols` is not specified, `byrow`
returns minimum for all numeric columns in `ds`.
Missing values are removed from the calculation. When all values in a row are missing, it returns `missing`.
Passing `threads = false` disables multithreaded computations.
See [`byrow(maximum)`](@ref), [`byrow(argmax)`](@ref), [`byrow(argmin)`](@ref)
# Examples
```jldoctest
julia> ds = Dataset(x=[1,2,3], y=[1.3,-2.4,5.5], z=[missing, 4,1])
3×3 Dataset
Row │ x y z
│ identity identity identity
│ Int64? Float64? Int64?
─────┼──────────────────────────────
1 │ 1 1.3 missing
2 │ 2 -2.4 4
3 │ 3 5.5 1
julia> byrow(ds, minimum)
3-element Vector{Union{Missing, Float64}}:
1.0
-2.4
1.0
julia> byrow(ds, minimum, [1,3])
3-element Vector{Union{Missing, Int64}}:
1
2
1
```
@@@@argmax@@@@
byrow(ds::AbstractDataset, argmax, cols; [by = identity, threads])
Return the column name of the maximum result of calling function `by` on each values in each row (of selected columns). If `cols` is not specified, `byrow`
passes all numeric columns in `ds`.
Missing values are removed from the calculation. When all values in a row are missing, it returns `missing`.
Passing `threads = false` disables multithreaded computations.
See [`byrow(maximum)`](@ref), [`byrow(minimum)`](@ref), [`byrow(argmin)`](@ref)
# Examples
```jldoctest
julia> ds = Dataset(x=[1,2,missing], y=[1.3,-2.4,missing], z=[missing, 4,missing])
3×3 Dataset
Row │ x y z
│ identity identity identity
│ Int64? Float64? Int64?
─────┼───────────────────────────────
1 │ 1 1.3 missing
2 │ 2 -2.4 4
3 │ missing missing missing
julia> byrow(ds, argmax)
3-element PooledArrays.PooledVector{Union{Missing, Symbol}, UInt32, Vector{UInt32}}:
:y
:z
missing
julia> byrow(ds, argmax, 1:2, by = abs)
3-element PooledArrays.PooledVector{Union{Missing, Symbol}, UInt32, Vector{UInt32}}:
:y
:y
missing
```
@@@@argmin@@@@
byrow(ds::AbstractDataset, argmin, cols; [by = identity, threads])
Return the column name of the minimum result of calling function `by` on each values in each row (of selected columns). If `cols` is not specified, `byrow`
passes all numeric columns in `ds`.
Missing values are removed from the calculation. When all values in a row are missing, it returns `missing`.
Passing `threads = false` disables multithreaded computations.
See [`byrow(maximum)`](@ref), [`byrow(minimum)`](@ref), [`byrow(argmax)`](@ref)
# Examples
```jldoctest
julia> ds = Dataset(x=[1,2,missing], y=[1.3,-2.4,missing], z=[missing, 4,missing])
3×3 Dataset
Row │ x y z
│ identity identity identity
│ Int64? Float64? Int64?
─────┼───────────────────────────────
1 │ 1 1.3 missing
2 │ 2 -2.4 4
3 │ missing missing missing
julia> byrow(ds, argmin)
3-element PooledArrays.PooledVector{Union{Missing, Symbol}, UInt32, Vector{UInt32}}:
:x
:y
missing
julia> byrow(ds, argmin, 1:2, by = abs)
3-element PooledArrays.PooledVector{Union{Missing, Symbol}, UInt32, Vector{UInt32}}:
:x
:x
missing
```
@@@@issorted@@@@
byrow(ds::AbstractDataset, issorted, cols; [rev = false, lt = isless, threads])
Test whether the values in rows (in selected `cols`) are in sorted order. Passing `rev = true` test whether the values in rows are in descending order. By default, the order of values is check by the `isless` function, however, user may pass any function to `lt`. The passed function to `lt` must accept two arguments where `byrow` calls `!lt(x2, x1)` when `rev = false` and `!lt(x1, x2)` when `rev = true` on consecutive column values.
Missing values are larger than any other values. User may pass a customised funtion to `lt` to skip missing values.
Passing `threads = false` disables multithreaded computations.
See [`byrow(isequal)`](@ref), [`byrow(isless)`](@ref), [`byrow(in)`](@ref)
# Examples
```jldoctest
julia> ds = Dataset(x=[1,2,missing], y=[1.3,-2.4,missing], z=[missing, 4,missing])
3×3 Dataset
Row │ x y z
│ identity identity identity
│ Int64? Float64? Int64?
─────┼───────────────────────────────
1 │ 1 1.3 missing
2 │ 2 -2.4 4
3 │ missing missing missing
julia> byrow(ds, issorted, :)
3-element Vector{Bool}:
1
0
1
julia> byrow(ds, issorted, :, lt = (x,y)->isless(abs(x), abs(y)))
3-element Vector{Bool}:
1
1
1
julia> byrow(ds, issorted, :, lt = isequal) # byrow checks !lt(y, x)
3-element Vector{Bool}:
1
1
0
julia> byrow(ds, issorted, :, lt = !isequal)
3-element Vector{Bool}:
0
0
1
```
@@@@join@@@@
byrow(ds::AbstractDataset, join, cols; [delim = "", last = "", threads])
For each row and selected columns convert values to string and join them into a single string, inserting the given delimiter (if any) between adjacent strings. If `last` is given, it will be used instead of `delim` between the last two strings. Missing values are converted to empty string and `true` and `false` converted to `1` and `0`, respectively.
Passing `threads = false` disables multithreaded computations.
@@@@hash@@@@
byrow(ds::AbstractDataset, hash, cols; [by = identity, threads])
Compute an integer hash code of result of calling `by` on each values in each row of selected `cols`. When `cols` is not specified `byrow` compute hash code for all columns in `ds`.
Passing `threads = false` disables multithreaded computations.
@@@@nunique@@@@