# Drop rows of an array containing missing values

**URL:** <https://discourse.julialang.org/t/drop-rows-of-an-array-containing-missing-values/105258>\
**Category:** General Usage\
**Tags:** arrays, missing-values\
**Created:** [October 21, 2023, 3:04am UTC](https://discourse.julialang.org/t/drop-rows-of-an-array-containing-missing-values/105258 "2023-10-21T03:04:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultratrader](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ultratrader/32/42836_2.png) [@ultratrader](https://discourse.julialang.org/u/ultratrader)\
**Post date:** [October 21, 2023, 3:04am UTC](https://discourse.julialang.org/t/drop-rows-of-an-array-containing-missing-values/105258/1 "2023-10-21T03:04:45Z")

</div>

Hi guys,

I want to drop rows containing missing values in an array. I can do this by converting the array to a df, and then using the skipmissing function from DataFrames.jl but I prefer to operate on an array rather than doing anything in the data frame to reduce memory consumption. CMIIW

```julia
function drop_missing(A::AbstractArray)
    ncol = size(A,2)
    a = []
    for i in eachrow(A)
        if sum(ismissing.(i))==0
        a = vcat(a,i)
        else
        end
    end
    return permutedims(reshape(a, (ncol, :)))
end

X = ["Alex" "A" 28; "Bond" "A" missing;
    "Anna" "B" 25; "cyntia" "B" 27;
    "Clara" "A" 22; "Danny" "B" 24]

drop_missing(X) # 5x3 matrix, excluding the second one

```

is there a better way to do this?? may be a more efficient way. plus how to inplace the original array?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 21, 2023, 5:25am UTC](https://discourse.julialang.org/t/drop-rows-of-an-array-containing-missing-values/105258/2 "2023-10-21T05:25:09Z")

</div>

I’m on the phone so can’t check but I’d probably write something like

```julia
A[.!(any.(ismissing, eachrow(A)), :]

```

---

<div class="post-metadata">

**Author:** ![ultratrader](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ultratrader/32/42836_2.png) [@ultratrader](https://discourse.julialang.org/u/ultratrader)\
**Post date:** [October 21, 2023, 7:39am UTC](https://discourse.julialang.org/t/drop-rows-of-an-array-containing-missing-values/105258/3 "2023-10-21T07:39:36Z")

</div>

Thank you, it works. just need to add an additional “)”.
