Skip to content

Support __arrow_c_array__ in viz() #425

@kylebarron

Description

@kylebarron

It would be nice to be able to visualize any array. Note that this should be before __geo_interface__ in the conversion steps.

You might want to do something like the following to ensure the field metadata isn't lost if extension types aren't installed.

if hasattr(obj, "__arrow_c_array__"):
    schema, _ = obj.__arrow_c_array__()

    class SchemaHolder:
        def __init__(self, capsule) -> None:
            self.capsule = capsule

        def __arrow_c_schema__(self):
            return self.capsule
        
    pyarrow_field = pa.field(SchemaHolder(schema))
    pyarrow_array = pa.array(obj)

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