A good way to filter an array with keeping its dimension

I want to filter nothing in an array with keeping its dimension.
Is there any better way to do this other than using reshape()?

x = [
    -0.240487   1.72634
    -0.946312   0.915657
    0.497511   3.77469
    -1.63141    1.31983
   nothing    nothing
   nothing    nothing
   nothing    nothing
   nothing    nothing
]
size(filter(!isnothing, x)) # (8,)

I want to get the following object as an output.

# Array{Float64,2}
 [
    -0.240487   1.72634
    -0.946312   0.915657
    0.497511   3.77469
    -1.63141    1.31983
]

First you have to define which rows you want to filter, e.g. what about rows 6 and 8 in

x = [
    -0.240487   1.72634
    -0.946312   0.915657
    0.497511   3.77469
    -1.63141    1.31983
   nothing    nothing
   nothing    0.76453
   nothing    nothing
   -0.47456    nothing
]
1 Like

True…
I want to filter all the rows that contains nothing.
Row 6 and 8 should be filtered in my case.

julia> x[.!any.(isnothing, eachrow(x)), :]
4×2 Array{Union{Nothing, Float64},2}:
 -0.240487  1.72634
 -0.946312  0.915657
  0.497511  3.77469
 -1.63141   1.31983
4 Likes

Thank you!
I’ve never used eachrow() before.