Skip to content

feature request: default implementation for list of structs #21

Description

@skyqrose

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():

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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