Merge two dataframes together

Hello, im trying merging or joining 2 dataframe on the same index.
i have just checked this page https://juliadata.github.io/DataFrames.jl/stable/man/joins/ and it seems all the join require the name of a column, but id like to use the index instead of column.

if it was possible to use something like:
join (df,df, on: index/row)

edit: merge!() seems to be perfect but its deprecated…

What does index mean? You’re treating these DataFrames like arrays? If so, can you use hcat?

julia> using DataFrames

julia> x = DataFrame(a = [2, 3])
2Γ—1 DataFrame
β”‚ Row β”‚ a     β”‚
β”‚     β”‚ Int64 β”‚
β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 1   β”‚ 2     β”‚
β”‚ 2   β”‚ 3     β”‚

julia> y = DataFrame(b = [3, 4])
2Γ—1 DataFrame
β”‚ Row β”‚ b     β”‚
β”‚     β”‚ Int64 β”‚
β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 1   β”‚ 3     β”‚
β”‚ 2   β”‚ 4     β”‚

julia> hcat(x, y)
2Γ—2 DataFrame
β”‚ Row β”‚ a     β”‚ b     β”‚
β”‚     β”‚ Int64 β”‚ Int64 β”‚
β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 1   β”‚ 2     β”‚ 3     β”‚
β”‚ 2   β”‚ 3     β”‚ 4     β”‚
2 Likes