连接数据

Julia 中的数据操作

Katerina Zahradova

Instructor

为何要连接

  • 数据集中尚未包含的更多信息
  • 不同来源的数据集
  • ...
Julia 中的数据操作

左连接

左连接

Julia 中的数据操作

左连接实操

更多连接信息见此处 here

# 对 chocolates 和 chocolate_companies 做左连接,使用 company 列
leftjoin(chocolates, chocolate_companies, on = :company)
1 https://dataframes.juliadata.org/stable/man/joins/
Julia 中的数据操作

在不同列名上连接

# 对 chocolates 和 chocolate_companies 做左连接,使用 company 与 company_name
leftjoin(chocolates, chocolate_companies, on = :company => :company_name)
Julia 中的数据操作

在多列上连接

# 对 chocolates 和 chocolate_companies 做左连接
# 使用 company 和 company_location 列
leftjoin(chocolates, chocolate_companies, 
                on = [:company => :company, :company_location => :company_location])
Julia 中的数据操作

速查表

leftjoin(left, right, on = :col)

  • 返回 left 的所有行和列,以及在 col 上与 left 匹配的 right

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

  • 当列名不同时时做左连接

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

  • 在多列上左连接
Julia 中的数据操作

Passons à la pratique !

Julia 中的数据操作

Preparing Video For Download...