Search code examples
dataframejulianullable

Using base math operators with Julia Nullables in julia-0.5


I am using Dataframes in Julia 0.5.1-pre+2 pulled and built locally from github, and I have also tried the Mac dmg download 0.5 download as well, and I am having trouble understanding how to properly work with nullables and nullable arrays.

df = DataFrame(x=rand(20), y=rand(20))

 mean(df[:x])
ERROR: MethodError: no method matching /(::Nullable{Float64}, ::Int64)

So this errors seems to be telling me that this operation isn't defined for a Nullable{Float} and Int and simply trying an operation like

Nullable(2.) / 1

will lead to the same error.

I am confused though from the documentation for DataFrames though, since it shows operations like:

mean(df[1])
median(df[1])

mean(df[:A])
median(df[:A])

df = DataFrame(A = 1:4, B = randn(4))
colwise(cumsum, df)

All of which lead to similar undefined method errors when executed on my machine.

I am not sure if this is either the correct behavior in the current ecosystem or a build/package version issue.


Solution

  • For some reason, you had the development (master) version of DataFrames installed. One possible way that can happen if you had run Pkg.develop("DataFrames") at some point.

    DataFrames is going through a major rewrite, and hence many things may not work correctly on the development version. The release versions should work correctly. Deleting your .julia folder got you back to the release version.

    You can check the status of your packages with the Pkg.status function. So for example

    julia> Pkg.status("DataFrames")
      - DataFrames                    0.8.4
    

    If any package has its master version installed, that will be specified in the result.

    julia> Pkg.status("JavaCall")
      - JavaCall                      0.4.2+             master 
    

    The function without any parameters Pkg.status() will show the status for all packages.