I have the following DataFrame:
julia> directories
247×133 DataFrame. Omitted printing of 127 columns
│ Row │ receiverId │ 2018-03-05 │ 2018-03-06 │ 2018-03-07 │
├─────┼──────────────────┼──────────────────────┼──────────────────────┼─────────────────────────┼
│ 1 │ 001bc50940820093 │ floor7:east:pat7302 │ floor7:east:pat7302 │ floor7:east:pat7302 │
│ 2 │ 001bc509408200fe │ floor5:south:pat5111 │ floor5:south:pat5111 │ floor5:southICU:pat5111 │
│ 3 │ 001bc5094082008e │ floor5:east:pat5307 │ floor5:east:pat5307 │ floor5:east:pat5307 │
│ 4 │ 001bc50940820018 │ floor7:south:ns04 │ floor7:south:ns04 │ floor7:south:ns04 │
│ 5 │ 001bc5094082005c │ floor5:west:ns02 │ floor5:west:ns02 │ floor5:west:ns02 │
│ 6 │ 001bc509408200ae │ floor8:west:ns01 │ floor8:west:ns01 │ floor8:west:ns01 │
│ 7 │ 001bc50940820028 │ floor7:south:pat7110 │ floor7:south:pat7110 │ floor7:south:pat7110 │
│ 8 │ 001bc50940820094 │ floor7:north:pat7217 │ floor7:north:pat7217 │ floor7:north:pat7217 │
│ 9 │ 001bc509408200b7 │ floor9:east:pat9301 │ floor9:east:pat9301 │ floor9:east:pat9301 │
│ 10 │ 001bc509408200c6 │ floor9:east:pat9304 │ floor9:east:pat9304 │ floor9:east:pat9304 │
⋮
│ 237 │ 001bc509408200f6 │ missing │ missing │ missing │
│ 238 │ 001bc50940820116 │ missing │ missing │ missing │
│ 239 │ 001bc509408200a6 │ missing │ missing │ missing │
│ 240 │ 001bc509408101f8 │ missing │ missing │ missing │
│ 241 │ 001bc50940820118 │ missing │ missing │ missing │
│ 242 │ 001bc5094082008d │ missing │ missing │ missing │
│ 243 │ 001bc5094082011a │ missing │ missing │ missing │
│ 244 │ 001bc50940820099 │ missing │ missing │ missing │
│ 245 │ 001bc50940820113 │ missing │ missing │ missing │
│ 246 │ 001bc5094082010a │ missing │ missing │ missing │
│ 247 │ 001bc509408200f2 │ missing │ missing │ missing │
I want to check if the receiverId 001bc509408200f6
is missing for a given date. I index the DataFrame in the following way, for a given date (column):
julia> directories[directories[:receiverId] .== "001bc509408200f6", Symbol("2018-03-05")]
1-element Array{Union{Missing, String},1}:
missing
Here, the type of the output is a 1-element Array{Union{Missing, String},1}
. If I use ismissing
, I get:
julia> ismissing(directories[directories[:receiverId] .== "001bc509408200f6", Symbol("2018-03-05")])
false
which is not the expected output (at least for me). If use use dot notation, since I am evaluating an array,
julia> ismissing.(directories[directories[:receiverId] .== "001bc509408200f6", Symbol("2018-03-05")])
1-element BitArray{1}:
true
I get the expected output in an unexpected (again, for me) type. Therefore, I can’t for example use it as the condition for an if
statement (at least I haven’t figured out how).
What’s the right way to check whether a value is missing when indexing a DataFrame with an array of Booleans? Note that if I index using numbers, e.g.
julia> ismissing(directories[237,2])
true
this just works. However, for the processing I’m working on, it’s easier to index by receiverId
and date (column) values.