Hi how’s it going,
I tried using hcat to stack each of these dataframes on top of each other, but it’s not really working as intended. I want to combine a list of dataframes, all with the same column names, into one big dataframe
Thanks
Hi how’s it going,
I tried using hcat to stack each of these dataframes on top of each other, but it’s not really working as intended. I want to combine a list of dataframes, all with the same column names, into one big dataframe
Thanks
you want vcat
, for vertical concatenation as opposed to hcat for horizontal concatenation.
julia> dfs= [DataFrame(rand(5,2)) for i in 1:5]
julia> reduce(vcat, dfs)
If you dataframes don’t have the same columns and you want to stack them on top of one another, filling in missing columns with missing
s, you can do
julia> dfs= [isodd(i) ? DataFrame(rand(5, 2)) : DataFrame(rand(5, 3)) for i in 1:5]
julia> reduce(vcat, dfs, cols = :union)
or “reduce” typing with:
df_union = vcat(dfs..., cols = :union)
Thanks guys!