Skip to content

byrow (sum) on a column containing vectors of numbers #52

Open
@sprmnt21

Description

@sprmnt21

I don't explain the reason for the following differences

julia> modify(compare(ds[!, r"lim"], ds[!, Not(r"lim")], on = 1:3 .=> 1:3, eq = !isless), 1:3=>byrow(x->x.*1))
6×4 Dataset
 Row │ a_lim=>a  b_lim=>b  c_lim=>c  row_function 
     │ identity  identity  identity  identity
     │ Bool?     Bool?     Bool?     Array…?
─────┼────────────────────────────────────────────
   1 │     true      true     false  [1, 1, 0]
   2 │     true     false      true  [1, 0, 1]
   3 │     true      true      true  [1, 1, 1]
   4 │    false      true     false  [0, 1, 0]
   5 │    false     false     false  [0, 0, 0]
   6 │     true     false     false  [1, 0, 0]

julia> modify(modify(compare(ds[!, r"lim"], ds[!, Not(r"lim")], on = 1:3 .=> 1:3, eq = !isless), 1:3=>byrow(x->x.*1)),4=>byrow(x->sum(x)))
6×4 Dataset
 Row │ a_lim=>a  b_lim=>b  c_lim=>c  row_function 
     │ identity  identity  identity  identity
     │ Bool?     Bool?     Bool?     Int64?
─────┼────────────────────────────────────────────
   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(modify(compare(ds[!, r"lim"], ds[!, Not(r"lim")], on = 1:3 .=> 1:3, eq = !isless), 1:3=>byrow(x->x.*1)),4=>x->sum.(x))
6×4 Dataset
 Row │ a_lim=>a  b_lim=>b  c_lim=>c  row_function 
     │ identity  identity  identity  identity
     │ Bool?     Bool?     Bool?     Int64?
─────┼────────────────────────────────────────────
   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(modify(compare(ds[!, r"lim"], ds[!, Not(r"lim")], on = 1:3 .=> 1:3, eq = !isless), 1:3=>byrow(x->x.*1)),4=>byrow(sum))
6×4 Dataset
 Row │ a_lim=>a  b_lim=>b  c_lim=>c  row_function 
     │ identity  identity  identity  identity
     │ Bool?     Bool?     Bool?     Array…?
─────┼────────────────────────────────────────────
   1 │     true      true     false  [1, 1, 0]
   2 │     true     false      true  [1, 0, 1]
   3 │     true      true      true  [1, 1, 1]
   4 │    false      true     false  [0, 1, 0]
   5 │    false     false     false  [0, 0, 0]
   6 │     true     false     false  [1, 0, 0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions