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

**URL:** https://discourse.julialang.org/t/how-do-i-recreate-excels-index-match-function-in-julia/63144
**Category:** New to Julia
**Tags:** dataframes, excel
**Created:** [June 18, 2021, 2:34pm UTC](https://discourse.julialang.org/t/how-do-i-recreate-excels-index-match-function-in-julia/63144 "2021-06-18T14:34:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Mitch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mitch/32/24224_2.png) [@Mitch](https://discourse.julialang.org/u/Mitch)
#### Post date: [June 18, 2021, 2:34pm UTC](https://discourse.julialang.org/t/how-do-i-recreate-excels-index-match-function-in-julia/63144/1 "2021-06-18T14:34:14Z")

</div>

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.

> **[Name Your Favorite Excel Function and I’ll Teach You its Pandas Equivalent](https://towardsdatascience.com/name-your-favorite-excel-function-and-ill-teach-you-its-pandas-equivalent-7ee4400ada9f)**
>
> In this post we leverage popular library, Pandas, to code out ways to achieve an Index/Match in Python code.

Is there an equivalent in Julia?

Thank you!

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [June 18, 2021, 2:40pm UTC](https://discourse.julialang.org/t/how-do-i-recreate-excels-index-match-function-in-julia/63144/2 "2021-06-18T14:40:00Z")

</div>

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

```julia
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    

```

---

<div class="post-metadata">

### Author: ![Mitch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mitch/32/24224_2.png) [@Mitch](https://discourse.julialang.org/u/Mitch)
#### Post date: [June 18, 2021, 3:00pm UTC](https://discourse.julialang.org/t/how-do-i-recreate-excels-index-match-function-in-julia/63144/3 "2021-06-18T15:00:31Z")

</div>

Thank you very much!
