I rather liked this suggestion in that other thread:
It seems reasonable to associate some meta data to columns in a DataFrame. Having to track them in a separate Dict would possibly backfire because you would have to maintain the consistency between two separate data structures.
Consider the case of reading data from a relational database. Each column has metadata like data type, length, precision, allow nulls, etc. Often these are good information that is very handy when processing query results.
Something like this would be fairly easy to implement in DataFrames?
putmeta!(df, :column1, @NT(kind = :level))
putmeta!(df, :column2, @NT(kind = :rate))
getmeta(df, :column1) # returns @NT(kind = :level)
colswith(df, t => t.kind == :level) # returns an iterator over :level columns
Generally speaking, I think in julia it’s better to avoid accessing the internals of an object directly (eg a.meta[:source] = "www.some.site"
) since a function can be generic and do similar things to objects that have different internal structure.
4 Likes