Skip to content

Commit c3e04c2

Browse files
committed
add byrow(join) to doc + add tests for it
1 parent 0809028 commit c3e04c2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

docs/src/man/byrow.md

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Generally, `byrow` is efficient for any `fun` which returns a single value for e
5757
* `isequal` : Return `true` when all values are equal. Optionally, a vector of values can be passed via the `with` keyword to compare equality with it.
5858
* `isless` : Return `true` when all values are less than passed vector(or column specified by its name) as `with`. Passing `rev = true` change `less` to `greater`.
5959
* `issorted` : Check if the values are sorted
60+
* `join`: Convert values in each row to string and join them into a single string, inserting the given delimiter (if any) between adjacent values. If `last` is given, it will be used instead of `delim` between the last two strings.
6061
* `maximum` : Return the maximum value
6162
* `mean` : Compute the mean value
6263
* `minimum` : Return the minimum value

test/byrow.jl

+17
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,23 @@
315315
@test byrow(sds2, in, 1:2, item = :x3) == [1,1,1,0,1]
316316
@test byrow(sds2, in, 1:2, item = sds2[!, 3])== [1,1,1,0,1]
317317
@test byrow(sds2, in, 1:2, item = sds2[:, 3])== [1,1,1,0,1]
318+
319+
ds = Dataset(x1 = ["A", "B,"], x2 =["TEA", "TOOOOL"])
320+
@test byrow(ds, join, r"x") == ["ATEA", "B,TOOOOL"]
321+
@test byrow(ds, join, r"x", delim = ",") == ["A,TEA", "B,,TOOOOL"]
322+
@test byrow(ds, join, r"x", last = ".") == ["ATEA.", "B,TOOOOL."]
323+
@test byrow(ds, join, r"x", last = "end", delim = "/-/") == ["A/-/TEAend", "B,/-/TOOOOLend"]
324+
325+
@test byrow(view(ds, [1,2], :), join, r"x") == ["ATEA", "B,TOOOOL"]
326+
@test byrow(view(ds, [1,2], :), join, r"x", delim = ",") == ["A,TEA", "B,,TOOOOL"]
327+
@test byrow(view(ds, [1,2], :), join, r"x", last = ".") == ["ATEA.", "B,TOOOOL."]
328+
@test byrow(view(ds, [1,2], :), join, r"x", last = "end", delim = "/-/") == ["A/-/TEAend", "B,/-/TOOOOLend"]
329+
330+
repeat!(ds, 1000)
331+
@test byrow(ds, join, r"x", threads = true) == repeat(["ATEA", "B,TOOOOL"], 1000)
332+
@test byrow(ds, join, r"x", threads = true, delim = ",") == repeat(["A,TEA", "B,,TOOOOL"], 1000)
333+
@test byrow(ds, join, r"x", threads = true, last = ".") == repeat(["ATEA.", "B,TOOOOL."], 1000)
334+
@test byrow(ds, join, r"x", threads = true, last = "end", delim = "/-/") == repeat(["A/-/TEAend", "B,/-/TOOOOLend"], 1000)
318335
end
319336

320337
@testset "cum*/! - sort/!" begin

0 commit comments

Comments
 (0)