-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathpassmissing.jl
48 lines (33 loc) · 1.07 KB
/
passmissing.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
module Testeachrow
using Test
using DataFrames
using DataFramesMeta
using Statistics
const ≅ = isequal
df = DataFrame(a = [1, 2, missing], b = [4, 5, 6])
@testset "passmissing by row" begin
no_missing(x::Int, y::Int) = x + y
df = DataFrame(a = [1, 2, missing], b = [4, 5, 6])
d = @transform df @byrow @passmissing :c = no_missing(:a, :b)
@test d.c ≅ [5, 7, missing]
d = @transform df @passmissing @byrow :c = no_missing(:a, :b)
@test d.c ≅ [5, 7, missing]
d = @transform df @byrow begin
:c = :a + :b
@passmissing :d = no_missing(:a, :b)
end
@test d.c ≅ d.d
d = @rselect df @passmissing :c = no_missing(:a, :b)
@test d.c ≅ [5, 7, missing]
d = @rselect df @passmissing :c = no_missing(:a, :b)
@test d.c ≅ [5, 7, missing]
d = @rselect df begin
:c = :a + :b
@passmissing :d = no_missing(:a, :b)
end
@test d.c ≅ d.d
d = @rorderby df @passmissing no_missing(:a, :b)
@test d ≅ df
@test_throws LoadError @eval @transform df @passmissing :c = :a + :b
end
end # module