Joining data

Data Manipulation in Julia

Katerina Zahradova

Instructor

Why we join

  • More information not already included in the dataset
  • Datasets from different sources
  • ...
Data Manipulation in Julia

Left join

Left Join

Data Manipulation in Julia

Left join in practice

More info about joins here

# Left join on chocolates and chocolate_companies, using company column
leftjoin(chocolates, chocolate_companies, on = :company)
1 https://dataframes.juliadata.org/stable/man/joins/
Data Manipulation in Julia

Joining on columns with different names

# Left join on chocolates and chocolate_companies, using company and company_name
leftjoin(chocolates, chocolate_companies, on = :company => :company_name)
Data Manipulation in Julia

Joining on multiple columns

# Left join on chocolates and chocolate_companies
# using company and company_location columns
leftjoin(chocolates, chocolate_companies, 
                on = [:company => :company, :company_location => :company_location])
Data Manipulation in Julia

Cheat sheet

leftjoin(left, right, on = :col):

  • returns all rows and columns from left, along with those rows of right that have a matching value in col with left

leftjoin(left, right, on = :col_left => :col_right):

  • left join when the columns don't have the same name

leftjoin(left, right, on = [:c1_l => :c1_r, ...]):

  • left join on multiple columns
Data Manipulation in Julia

Let's practice!

Data Manipulation in Julia

Preparing Video For Download...