I have a ratings
variable:
ratings = 10×3 DataFrames.DataFrame
│ Row │ Movie title │ Dean │ Sam │
├─────┼─────────────────────────────────────┼──────┼─────┤
│ 1 │ "Moonlight (2016)" │ 10 │ 0 │
│ 2 │ "Zootopia (2016)" │ 0 │ 0 │
│ 3 │ "Arrival (2016)" │ 10 │ 10 │
│ 4 │ "Hell or High Water (2016)" │ 10 │ 0 │
│ 5 │ "La La Land (2016)" │ 9 │ 0 │
│ 6 │ "The Jungle Book (2016)" │ 2 │ 0 │
│ 7 │ "Manchester by the Sea (2016)" │ 8 │ 0 │
│ 8 │ "Finding Dory (2016)" │ 4 │ 0 │
│ 9 │ "Captain America: Civil War (2016)" │ 6 │ 9 │
│ 10 │ "Moana (2016)" │ 0 │ 0 │
I then apply some elementwise filtering to it:
recommended_movies = ratings[Array(ratings[:Dean] .> 7) .& Array(ratings[:Sam] .== 0), :]
The above code, where I explicitly use 7
works as expected.
However, if I do const minimum_rating = 7
and then
recommended_movies = ratings[Array(ratings[:Dean] .> minimum_rating) .& Array(ratings[:Sam] .== 0), :]
it fails with
ERROR: LoadError: MethodError: no method matching isless(::Int64, ::Nullable{Int64})
Closest candidates are:
isless(!Matched::Nullable{Union{}}, ::Nullable) at nullable.jl:235
isless(!Matched::DataArrays.NAtype, ::Any) at /Users/adrian/.julia/v0.6/DataArrays/src/operators.jl:383
isless(::Real, !Matched::AbstractFloat) at operators.jl:97
It seems to me that this is the kind of refactoring that should Just Work™