-
Notifications
You must be signed in to change notification settings - Fork 4
Description
I have a list of structs representing row-major tabular data that I want to satisfy the Table protocol so that I can pass them to Explorer.DataFrame.new().
This is almost automatically works, except that it's specifically disabled for struct rows (but not map rows) in init_row()
:
table/lib/table/reader/enumerable.ex
Lines 54 to 56 in 5704327
defp columns_for(%_{} = _struct) do | |
:error | |
end |
Having a tabular data as a list of structs seems like it should be common case. Should this library support it?
A workaround would be to define my own custom implementation of the protocol. I can't define an implementation for List because it's already defined, and I don't want to overwrite the default in all cases, just for lists of structs. But I guess I could define a new struct that wraps the list, and then define the implementation for that.
My ideal implementation would keep the column order from the struct definition, instead of sorting the keys like it does for maps.