[DataFrames Question]: Inner join DataFrame Array?

Question:

Suppose I have an array of DataFrame t[1:10]. What is the neatest way to join them?

innerjoin(t[1], t[2], ..., on = :tag, ...)
# or
df = t[1]
for i in 2:10 
    df = innerjoin(df, t[i], on =...)
end

Both are fine! use what you feel is more readable.

I’m not sure which one would be more performant if that is important in this context, but probably the first method.

Thanks. Just realized that the 2nd is better, as number of tables might varies. Using 2:end can deal array of unknown lengths. It also feels faster, though I didn’t test.

You can also use splatting for the first method.

innerjoin(t..., on = :tag)
1 Like

This is exactly what I wanted in the 1st place! Thanks again.