-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
In what is sum different from count, in the following example?
julia> ds=Dataset(a=rand(6),a_lim=0.75,b=rand(6),b_lim=0.33,c=rand(6),c_lim=0.25)
6×6 Dataset
Row │ a a_lim b b_lim c c_lim
│ identity identity identity identity identity identity
│ Float64? Float64? Float64? Float64? Float64? Float64?
─────┼────────────────────────────────────────────────────────────────
1 │ 0.503853 0.75 0.231149 0.33 0.485659 0.25
2 │ 0.182826 0.75 0.753766 0.33 0.0138429 0.25
3 │ 0.349623 0.75 0.109759 0.33 0.00354937 0.25
4 │ 0.984995 0.75 0.00684881 0.33 0.546865 0.25
5 │ 0.90003 0.75 0.483134 0.33 0.588903 0.25
6 │ 0.246932 0.75 0.75743 0.33 0.660182 0.25
julia> modify(compare(ds[!, r"lim"], ds[!, Not(r"lim")], on = 1:3 .=> 1:3, eq = !isless), 1:3=>byrow(count))
6×4 Dataset
Row │ a_lim=>a b_lim=>b c_lim=>c row_count
│ identity identity identity identity
│ Bool? Bool? Bool? Int32?
─────┼─────────────────────────────────────────
1 │ true true false 2
2 │ true false true 2
3 │ true true true 3
4 │ false true false 1
5 │ false false false 0
6 │ true false false 1
julia> modify(compare(ds[!, r"lim"], ds[!, Not(r"lim")], on = 1:3 .=> 1:3, eq = !isless), 1:3=>byrow(sum))
ERROR: InexactError: Bool(2)
Stacktrace:
while the following are working
count(compare(ds[!, r"lim"], ds[!, Not(r"lim")], on = 1:3 .=> 1:3, eq = !isless)[1,:])
sum(compare(ds[!, r"lim"], ds[!, Not(r"lim")], on = 1:3 .=> 1:3, eq = !isless)[1,:])
# or also
modify(modify(compare(ds[!, r"lim"], ds[!, Not(r"lim")], on = 1:3 .=> 1:3, eq = !isless), 1:3=>x->Int.(x)), 1:3=>byrow(sum))
Metadata
Metadata
Assignees
Labels
No labels