I have 3 arrays with which I´d like to make a dataframe where each column corresponds to an array ( column 1 = abc, column 2 = def, column 3 = ghi) and the column names to the names of the arrays. I tried hcat but I get an error because my arrays don`t have the same length.
That won’t work, as OP said this will raise an error:
julia> DataFrame(abc = abc, def = def)
ERROR: DimensionMismatch("column :abc has length 5 and column :def has length 3")
This is just how DataFrames works - columns have to be the same length. You need to ask yourself:
Is a DataFrame the right structure for my data? Why do I want to use a DataFrame if the columns aren’t the same length?
If the answer to (1) is yes I really want a DataFrame, what should be stored in shorter columns in those rows for which information in the longer columns is available? To make it concrete, your table looks like this:
abc
def
ghi
6
“a”
87
7
“b”
?
8
“c”
?
9
?
?
What’s in those question marks? If there’s no natural correspondence between the value of abc and ghi in a given row, then maybe a DataFrame just isn’t the right storage format for your data.