Jake Yanez
Jake Yanez

Reputation: 3

Why am I receiving "TypeError: non-boolean (DataArrays.NAtype) used in boolean context"?

I am wondering if anybody can explain to me what this error means, and possibly how to resolve it. I can include the whole program of code if necessary, but here is the error message I am receiving, as well as the part of the program causing it.

    for i =1:num_hitters
    if hitters[i,:Position] == "OF"
outfield=vcat(outfield,fill(1,1))
catchers=vcat(catchers,fill(0,1))
firstbase=vcat(firstbase,fill(0,1))
secondbase=vcat(secondbase,fill(0,1))
thirdbase=vcat(thirdbase,fill(0,1))
shortstop=vcat(shortstop,fill(0,1))
    elseif hitters[i,:Position] == "C"
        outfield=vcat(outfield,fill(0,1))
            catchers=vcat(catchers,fill(1,1))
        firstbase=vcat(firstbase,fill(0,1))
            secondbase=vcat(secondbase,fill(0,1))
            thirdbase=vcat(thirdbase,fill(0,1))
            shortstop=vcat(shortstop,fill(0,1))
    elseif hitters[i,:Position] == "1B"
        outfield=vcat(outfield,fill(0,1))
            catchers=vcat(catchers,fill(0,1))
        firstbase=vcat(firstbase,fill(1,1))
            secondbase=vcat(secondbase,fill(0,1))
            thirdbase=vcat(thirdbase,fill(0,1))
            shortstop=vcat(shortstop,fill(0,1))
elseif hitters[i,:Position] == "2B"
        outfield=vcat(outfield,fill(0,1))
            catchers=vcat(catchers,fill(0,1))
        firstbase=vcat(firstbase,fill(0,1))
            secondbase=vcat(secondbase,fill(1,1))
            thirdbase=vcat(thirdbase,fill(0,1))
            shortstop=vcat(shortstop,fill(0,1))
elseif hitters[i,:Position] == "3B"
        outfield=vcat(outfield,fill(0,1))
            catchers=vcat(catchers,fill(0,1))
        firstbase=vcat(firstbase,fill(0,1))
            secondbase=vcat(secondbase,fill(0,1))
            thirdbase=vcat(thirdbase,fill(1,1))
            shortstop=vcat(shortstop,fill(0,1))
elseif hitters[i,:Position] == "SS"
        outfield=vcat(outfield,fill(0,1))
            catchers=vcat(catchers,fill(0,1))
        firstbase=vcat(firstbase,fill(0,1))
            secondbase=vcat(secondbase,fill(0,1))
            thirdbase=vcat(thirdbase,fill(0,1))
        firstbase=vcat(firstbase,fill(0,1))
            shortstop=vcat(shortstop,fill(1,1))
    else
        outfield=vcat(outfield,fill(0,1))
            catchers=vcat(catchers,fill(0,1))
        firstbase=vcat(firstbase,fill(0,1))
        secondbase=vcat(secondbase,fill(0,1))
            thirdbase=vcat(thirdbase,fill(0,1))
            shortstop=vcat(shortstop,fill(1,1))
      end
    end

Here is the error

    TypeError: non-boolean (DataArrays.NAtype) used in boolean context
 in create_lineups at C:\Users\Jake\Documents\GitHub\MLB_DFS_ALGO.jl:176
 in include_string at loading.jl:288
 in eval at C:\Users\Jake\.julia\v0.4\Atom\src\Atom.jl:3
 [inlined code] from C:\Users\Jake\.julia\v0.4\Atom\src\eval.jl:39
 in anonymous at C:\Users\Jake\.julia\v0.4\Atom\src\eval.jl:108
 in withpath at C:\Users\Jake\.julia\v0.4\Requires\src\require.jl:37
 in withpath at C:\Users\Jake\.julia\v0.4\Atom\src\eval.jl:53
 [inlined code] from C:\Users\Jake\.julia\v0.4\Atom\src\eval.jl:107
 in anonymous at task.jl:58

If anybody can explain why this is happening, or point to one of my stupid errors I would greatly appreciate it.

Upvotes: 0

Views: 757

Answers (1)

ARM
ARM

Reputation: 1550

It means your DataFrame contains at least one NA. You need to either make sure the data contains no missing values or explicitly handle them before attempting to compare them with ==.

Upvotes: 2

Related Questions