# How do I recreate excel's index match function in Julia?

Hey, thanks for the help!

I need to match the rows from column x in dataframe two, with the correct rows in data frame 1 to form a new column. The problem is visually described and solved in Python in the link below.

Is there an equivalent in Julia?

Thank you!

If I understand that medium post correctly itβs just a left join, so in DataFrames:

``````julia> using DataFrames

julia> df_1 = DataFrame(id = [1002, 1004, 1006],
first_name = ["Cersei", "Daenerys", "Arya"])
3Γ2 DataFrame
Row β id     first_name
β Int64  String
ββββββΌβββββββββββββββββββ
1 β  1002  Cersei
2 β  1004  Daenerys
3 β  1006  Arya

julia> df_2 = DataFrame(id = [1003, 1004, 1005, 1002, 1006],
last_name = ["Tyrell", "Targaryen", "Snow", "Lannister", "Stark"])
5Γ2 DataFrame
Row β id     last_name
β Int64  String
ββββββΌββββββββββββββββββ
1 β  1003  Tyrell
2 β  1004  Targaryen
3 β  1005  Snow
4 β  1002  Lannister
5 β  1006  Stark

julia> leftjoin(df_1, df_2, on = :id)
3Γ3 DataFrame
Row β id     first_name  last_name
β Int64  String      String?
ββββββΌββββββββββββββββββββββββββββββ
1 β  1004  Daenerys    Targaryen
2 β  1002  Cersei      Lannister
3 β  1006  Arya        Stark
``````
4 Likes

Thank you very much!