Inner join by comparing column values

I just wanted to check if we can do inner join and fetch result of matching rows by comparing column values of two data frames.

Currently I’ve tried below code and getting error “ArgumentError: All elements of on argument to join must be Symbol or Pair{Symbol, Symbol}.”


innerjoin(df2, df1, on = [:DPRT_CD, :timeline => (>=, <=)], makeunique = true)

df2

3×5 DataFrame
 Row │ c      d       DPRT_TML DPRT_CD  timeline
     │ Int64  String  Int64         String       Int64
─────┼────────────────────────────────────────────────────
   1 │     1  f                786  ABC                50
   2 │     2  g                846  DEF                50
   3 │     3  h                915  ABC                50

df1

5×5 DataFrame
 Row │ DPRT_CD  timeID  timeStart  timeEnd  timeline
     │ String       Int64       Int64          Int64        Int64
─────┼───────────────────────────────────────────────────────────────
   1 │ ABC                   1              0           59        50
   2 │ ABC                   2             60          119        50
   3 │ ABC                   3            120          179        50
   4 │ ABC                   4            180          239        50
   5 │ ABC                   5            240          299        50

I’m not sure if I’m understanding the question. If you want to make a join matching rows where both DPRT_CD and timeline are equal in each dataframe, you can do:

innerjoin(df2, df1, on = [:DPRT_CD, :timeline], makeunique = true)

Then, the matching would be when rows in one dataframe have the same :DPRT_CD and :timeline as the other dataframe.

I guess you want to perform a join using a condition. Use Readme · FlexiJoins.jl to achieve this. In the future we might add it to DataFrames.jl

@bkamins Yes, you are correct this is what I am looking for. Thanks for shedding lights on it.