title: How convert between different kinds of multidimensional arrays in Julia
body: <p>I'm migrating from python/numpy to julia. I'm really confused by Julia's multidimensional arrays and it feels like there is some additional level of  complexity / hassle (in comparison to numpy). </p>
  
  <p>There is distinction between 1)row-vectros 2)column-vectors, 3)multidimensional arrays and 4)nested arrays (=Arrays of arrays). That would be all fine (perhaps useful for performance optimization), assuming there is simple way how to convert between them. But I cannot figure out how to do it.</p>
  
  <p><strong>Simple example:</strong> 
  I just try to generate 2D rectangular grid of points and plot them </p>
  
  <pre><code>
  ps = [ [ix*0.1 iy*0.1] for ix=1:10, iy=1:10 ]
  # 10×10 Array{Array{Float64,2},2}:
  # Oh, this is nested array? I wand just simple 3D array 10x10x2
  
  scatter( ps[:,:,1], ps[:,:,2], markersize = 2, markerstrokewidth = 0, aspect_ratio=:equal )
  # ERROR: BoundsError: attempt to access 10×10 Array{Array{Float64,2},2} at index [Base.Slice(Base.OneTo(10)), Base.Slice(Base.OneTo(10)), 2]
  
  sh = size(ps)
  # (10,10)
  
  ps = reshape( ps, ( sh[1]*sh[2],2) )
  # ERROR: DimensionMismatch("new dimensions (100, 2) must be consistent with  array size 100")
  # Oh dear :(
  
  ps = reshape( ps, ( sh[1]*sh[2],:) )
  # 100×1 Array{Array{Float64,2},2}
  
  xs = ps[:,1]
  # 100-element Array{Array{Float64,2},1}
  # ??? WTF? ... this arrays looks like whole 'ps' 
  ys = ps[:,2] 
  # ERROR: BoundsError: attempt to access 100×1 Array{Array{Float64,2},2} at index [Base.Slice(Base.OneTo(100)), 2]
  
  xs = ps[:][1]
  # 1×2 Array{Float64,2}: 
  #  0.1  0.1
  #  But I want all xs  (ps[:,1]), not (ps[1,:]) 
  
  # Let's try some broadcasting
  xs = ps.[1]
  # ERROR: syntax: invalid syntax "ps.[1]"
  xs = .ps[1]
  # ERROR: syntax: invalid identifier name "."
  
  
  # Perhaps transpose will help?
  ps_ = ps'   #' stackoverflow syntax highlighting for Julia is broken ?
  # 1×100 LinearAlgebra.Adjoint{LinearAlgebra.Adjoint{Float64,Array{Float64,2}},Array{Array{Float64,2},2}}:
  # OMG! ... That is even worse
  
  scatter( ps[:,1], ps[:,2], markersize = 2, markerstrokewidth = 0, aspect_ratio=:equal )
  # Nope
  
  </code></pre>
  
  <p>OK this somehow works. But still I need to figure out how to convert between the different shapes of arrays above</p>
  
  <pre><code>using Plots
  ps = [ [ix*0.1 iy*0.1] for ix=1:10, iy=1:10 ]
  ps = vcat(ps...)
  xs = ps[:,1]
  ys = ps[:,2]
  scatter( xs, ys, markersize = 2, markerstrokewidth = 0, aspect_ratio=:equal )
  
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Maybe it could be good to list some tutorials where I was searching the answer before I asked:</p>
  
  <ul>
  <li><a href="https://juliadocs.github.io/Julia-Cheat-Sheet/" rel="nofollow noreferrer">https://juliadocs.github.io/Julia-Cheat-Sheet/</a></li>
  <li><a href="https://cheatsheets.quantecon.org/" rel="nofollow noreferrer">https://cheatsheets.quantecon.org/</a></li>
  <li><a href="https://learnxinyminutes.com/docs/julia/" rel="nofollow noreferrer">https://learnxinyminutes.com/docs/julia/</a></li>
  <li><a href="https://juliabyexample.helpmanual.io/" rel="nofollow noreferrer">https://juliabyexample.helpmanual.io/</a></li>
  <li><a href="https://julia.guide/broadcasting" rel="nofollow noreferrer">https://julia.guide/broadcasting</a></li>
  </ul>