JuliaData / DataFrames.jl

In-memory tabular data in Julia
https://dataframes.juliadata.org/stable/
Other
1.72k stars 367 forks source link

unnest #3116

Open jariji opened 2 years ago

jariji commented 2 years ago

Extract a table-valued column into top-level columns. Code by Bogumił Kamiński on Slack.

unnest(df, col) = flatten(
    select(df, Not(col), col => ByRow(Tables.columntable) => AsTable), 
    names(df, Not(col))
)

This might come with its opposite, nest.

See also tidyr - nest and unnest.

bkamins commented 2 years ago

OK, let us decide on these + https://github.com/JuliaData/DataFrames.jl/issues/2767 and https://github.com/JuliaData/DataFrames.jl/issues/2890 in 1.5 release.

This requires a careful design, especially, handling the case when unnested data frames do not have matching column names.

bkamins commented 1 year ago

x-ref: https://github.com/JuliaData/DataFrames.jl/issues/3005

bkamins commented 1 year ago

Do we want unnest to support only data frames, or also other Tables.jl tables? For row-like objects I think that #3005 solution with Tables.dictrowtable is good enough.

bkamins commented 1 year ago

We could not make a decision if we want it or no, so I keep this open. When working on it: