Merge two dataframes together

Hello, im trying merging or joining 2 dataframe on the same index.
i have just checked this page Joins · DataFrames.jl 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…

1 Like

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     │
3 Likes