JuliaData / DataFrames.jl

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

Feature request: for metadata! to accept a dictionary as input #3469

Open alex-s-gardner opened 1 week ago

alex-s-gardner commented 1 week ago

To copy metadata between data frames (df1 and df2) requires:

md = DataFrames.metadata(df1)
for k in keys(md)
    DataFrames.metadata!(df2, k, md[k])
end

It would be convenient if metadata! could directly accept metadata Dict() output so that the above becomes:

DataFrames.metadata!(df2, DataFrames.metadata(df1))

I suspect this would also be handy for setting multiple metadata fields with a single Dict()

bkamins commented 1 week ago

Currently https://github.com/JuliaData/TableMetadataTools.jl is intended to support such operations as in DataAPI.jl we wanted to keep a minimal API that is required. Would this extra package meet your needs?

alex-s-gardner commented 1 week ago

To me its seems that simplifying the copying of metadata between data frames would be best handled in native DataFrames.jl as this is an entry point for most people. I would think that the change to code would be minimal as it would just be a simple DataFrames.metadata! dispatch on a dictionary. But you'll certainly have a more informed view on this than I.