Reputation: 2902
This stack link shows how to return booleans
for the missing
values in an array.
For example:
julia> A = [1, 2, 3, missing, 4, 5, 6, missing, 7, 8, missing, 9, 10]
13-element Array{Union{Missing, Int64},1}:
1
2
3
missing
4
5
6
missing
7
8
missing
9
10
julia> ismissing.(A)
13-element BitArray{1}:
false
false
false
true
false
false
false
true
false
false
true
false
false
How do you return their indices?
Upvotes: 6
Views: 3901
Reputation: 2902
Using the same example, you can do this:
julia> A = [1, 2, 3, missing, 4, 5, 6, missing, 7, 8, missing, 9, 10]
13-element Array{Union{Missing, Int64},1}:
1
2
3
missing
4
5
6
missing
7
8
missing
9
10
# Below are the indices of the missing elements.
julia> findall(ismissing, A)
3-element Array{Int64,1}:
4
8
11
You can also find if any or all elements are missing
, and the first and last indices:
julia> any(ismissing, A)
true
julia> all(ismissing, A)
false
julia> findfirst(ismissing, A)
4
julia> findlast(ismissing, A)
11
Upvotes: 5