Is there any built-in function to convert a matrix to a DataFrame with the structure of a second DataFrame ?
i.e. :
df = DataFrame(a = [1,2,3], b= ["a","b","c"])
# Option 1, types not promoted
dfnames = names(df)
m = [4 "d"; 5 "e"]
df2 = DataFrame(m,dfnames) # doesn't promote types
# Option 2, manual assignment
df2 = similar(df,size(m,1))
[df2[:,cidx] = m[:,cidx] for cidx in axes(df2,2)]
df2 # fine
I have scrolled through the doc for the DataFrame constructor and didnβt find anything.. it would be nice to have something like:
df = DataFrame(matrix,otherdf)