Le lundi 03 octobre 2016 à 08:21 -0700, Min-Woong Sohn a écrit : > > I am using DataFrames from master branch (with NullableArrays as the > default) and was wondering how the following should be done: > > df = DataFrame() > df[:A] = NullableArray([1,2,3]) > > The following are not allowed or return wrong values: > > df[1,:A] == 1 # false > df[1,:A] > 1 # MethodError: no method matching isless(::Int64, > ::Nullable{Int64}) > df[3,:A] + 1 # MethodError: no method matching > +(::Nullable{Int64}, ::Int64) > > How should I get around these issues? Does anybody know if there is a > plan to support these kinds of computations directly? These operations currently work (after loading NullableArrays) if you rewrite 1 as Nullable(1), eg. df[1, :A] == Nullable(1). But the two first return a Nullable{Bool}, so you need to call get() on the result if you want to use them e.g. with an if. As an alternative, you can use isequal().
There are discussions as regards whether mixing Nullable and scalars should be allowed, as well as whether these operations should be moved into Julia Base. See in particular https://github.com/JuliaStats/NullableArrays.jl/pull/85 https://github.com/JuliaLang/julia/pull/16988 Anyway, the best approach to work with data frames is probably to use frameworks like AbstractQuery.jl and Query.jl, which are not yet completely ready to handle Nullable, but should make this easier. Regards