Skip to content

Support missing key-value pairs when creating array #386

Open

Description

@mrocklin

It looks like the JSON parser is able to avoid missing key-value pairs for option types

In [3]: nd.parse_json('{x: int, y: ?int}', '{"x": 5}')
Out[3]: 
nd.array([5, NA],
         type="{x: int32, y: ?int32}")

This is great. It would be much greater if it also worked when creating an array from Python objects (this is, at least for me, far more valuable than parsing text).

In [5]: nd.array({'x': 5}, '{x: int, y: ?int}')
BroadcastError: python dict does not contain the field "y" as required by the data type {x: int32, y: ?int32}

While I'm here, it's odd that those two functions have reversed signatures.

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