codedthinking / Kezdi.jl

Julia package for data manipulation and analysis
https://codedthinking.github.io/Kezdi.jl/
Other
21 stars 0 forks source link

bug: @if does not evaluate Boolean-valued columns #92

Closed korenmiklos closed 5 days ago

korenmiklos commented 5 days ago
julia> @count @if foreign_winner
ERROR: LoadError: MethodError: Cannot `convert` an object of type
  Symbol to an object of type
  Union{Bool, Expr}

vs

julia> @count @if foreign_winner == true
340856
korenmiklos commented 5 days ago

This was only an error in the struct Command. Works now:

julia> df = @generate df boolcol = (s == "a")
10×5 DataFrame
 Row │ x      y      z      s        boolcol
     │ Int8?  Int8?  Int8?  String3  Bool
─────┼───────────────────────────────────────
   1 │     1      4     -1  a           true
   2 │     2      9      1  a           true
   3 │     3     10     -1  a           true
   4 │     4     15      1  a           true
   5 │     5     16     -1  b          false
   6 │     6     21      1  b          false
   7 │     7     22     -1  b          false
   8 │     8     27      1  b          false
   9 │     9     28     -1  c          false
  10 │    10     33      1  c          false

julia> @keep df @if boolcol
4×5 SubDataFrame
 Row │ x      y      z      s        boolcol
     │ Int8?  Int8?  Int8?  String3  Bool
─────┼───────────────────────────────────────
   1 │     1      4     -1  a           true
   2 │     2      9      1  a           true
   3 │     3     10     -1  a           true
   4 │     4     15      1  a           true