Hi,
I am trying to concatenate vectors of different length (can we merge vectors of different lengths?) into a dataframe or table but nothing seems to work. I will share my code.
g = loadtable("all_files" ; spacedelim = true, filenamecol = "files")
df1 = DataFrame(g)
Age = DataFrame()
r = []
for i = 2:length(g)
global Age , r
if [g.columns.files[i-1]] == [g.columns.files[i]]
r = append!(r , g.columns.logAge[i-1])
else
Age[:,i-1] = r
r = []
end
end
Here’s an example of what happens if you try to extend a column of a data frame without extending the other columns by the same amount:
julia> using DataFrames
julia> df = DataFrame(a=1:2, b=3:4)
2Ă—2 DataFrame
│ Row │ a │ b │
│ │ Int64 │ Int64 │
├─────┼───────┼───────┤
│ 1 │ 1 │ 3 │
│ 2 │ 2 │ 4 │
julia> append!(df.b, [5, 6])
4-element Array{Int64,1}:
3
4
5
6
julia> df
Error showing value of type DataFrame:
ERROR: AssertionError: Data frame is corrupt: length of column
:b (4) does not match length of column 1 (2). The column vector
has likely been resized unintentionally (either directly or
because it is shared with another data frame).
Note that the data frame gets corrupted after you extend column b.
An MWE ns a “minimum working example”. and just means a small set of code that I can copy and paste (without having to download any other files etc.) that results in the error you are experiencing.