How to split a vector (or a dataframe) in two parts?

julia> y=collect(1:10)
10-element Vector{Int64}:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10

julia> a,b = @views y[1:end÷2],y[end÷2+1:end]
([1, 2, 3, 4, 5], [6, 7, 8, 9, 10])

you can remove @views to do copies. Or maybe this is not simple enough?

3 Likes