Skip to content

Add method to horizontally concatenate two (or more) tables of possibly different type #30

@ablaom

Description

@ablaom

This has come up in ML workflows; see JuliaAI/MLJ.jl#915. Would TableOperations.jl be the appropriate place for this?

What I have in mind is a simple concatenation - not a fancy join. So, if a column name of table1 appears in table2, then the table2 column just gets added with its name modified.

The tricky part is deciding on what the return type should be. I don't have fixed ideas about this, but perhaps if the tables do have the same type, and that is a sink type, then that is also the return type.

Although it is not a part of the public API, I see that TableTransforms.jl has an implementation. (To get the final table, the type of the first table is materialized.):

julia> table1
3×2 DataFrame
 Row │ x        z        
     │ Char     Float64  
─────┼───────────────────
   1 │ 𘂯       0.673471
   2\U3f846  0.360792
   3\Ud50cb  0.68075

julia> table2
(x = [0.41754294943943493, 0.7713462387833814, 0.9189998773436003], y = ['\U84fa1', '\U5e144', '\U872a4'])

julia> TableTransforms.tablehcat([table1, table2])
3×4 DataFrame
 Row │ x        z         x_        y       
     │ Char     Float64   Float64   Char    
─────┼──────────────────────────────────────
   1 │ 𘂯       0.673471  0.417543  \U84fa1
   2\U3f846  0.360792  0.771346  \U5e144
   3\Ud50cb  0.68075   0.919     \U872a4

cc @ExpandingMan @juliohm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions