Hi, I am trying to do an ‘as of’ merge in Julia with two large Dataframes, based on the time and the equipment_id provided. As a manner of example, let me introduce the two df.head()
using DataFrames
df1 = DataFrame(
date = DateTime.(["2022-02-20T08:05:22", "2022-02-20T08:05:42",
"2022-02-20T08:05:52", "2022-02-20T08:07:32",
"2022-02-20T08:07:32", "2022-02-20T08:08:05"]),
equipment_id = 165,
loaded = "f",
percent_grade = [0,-1,-3,-1,0,-8]
)
df2 = DataFrame(
date = DateTime.(["2022-02-20T08:05:24","2022-02-20T08:05:29",
"2022-02-20T08:05:34","2022-02-20T08:05:39",
"2022-02-20T08:05:44","2022-02-20T08:05:49"]),
truck = "T67",
equipment_id = 165,
value = [149.85,55.85,0,61.9,81.8,0]
)
Where the expected result has to looks like this:
df3 = DataFrame(
date = DateTime.(["2022-02-20T08:05:24","2022-02-20T08:05:29",
"2022-02-20T08:05:34","2022-02-20T08:05:39",
"2022-02-20T08:05:44","2022-02-20T08:05:49"]),
truck = "T67",
equipment_id = 165,
loaded = "f",
value = [149.85,55.85,0,61.9,81.8,0],
percent_grade = [0,0,0,0,-1,-1]
)
As you noted, the “date” column present in both DataFrames aren’t able me to do an exact match join. That’s why I am trying to do an as of merge. The closest solution that I have found is this. However, the “double cursor” thing makes the problem even more complicated.
Hope you can help me with this.
Thanks in advance.
Regards