2016-06-30 7 views
0

Ich wundere mich, wenn jemand mir erklären kann, was dieser Fehler bedeutet, und möglicherweise, wie man es löst. Ich kann das ganze Programm des Codes bei Bedarf einschließen, aber hier ist die Fehlermeldung, die ich empfange, sowie der Teil des Programms, der es verursacht.Warum erhalte ich "TypeError: non-boolean (DataArrays.NAtype) im booleschen Kontext"?

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 

Hier ist der Fehler

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 

Wenn jemand erklären kann, warum dies geschieht, oder zeigen Sie auf einer meiner dummen Fehler, die ich es sehr zu schätzen würde.

Antwort

3

Es bedeutet, dass Ihr DataFrame mindestens eine NA enthält. Sie müssen entweder sicherstellen, dass die Daten keine fehlenden Werte enthalten, oder sie explizit behandeln, bevor Sie sie mit == vergleichen.

+0

Danke für die Hilfe, war nicht sicher, ob ich die leeren Zeilen im DataFrame löschen musste oder nicht, aber jetzt weiß ich, dass ich es tue. –