Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-12677

[Python] Add a mask argument to pyarrow.StructArray.from_arrays

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • None
    • 5.0.0
    • Python

    Description

      The python API for creating StructArray from a list of array doesn't allow to pass a missing value mask.

      At the moment the only way to create a StructArray with missing value is to use `pyarrow.array` and passing a vector of tuple.

      >>> pyarrow.array(
          [
              None,
              (1, "foo"),
          ],
          type=pyarrow.struct(
              [pyarrow.field('col1', pyarrow.int64()), pyarrow.field("col2", pyarrow.string())]
          )
      )
      -- is_valid:
        [
          false,
          true
        ]
      -- child 0 type: int64
        [
          0,
          1
        ]
      -- child 1 type: string
        [
          "",
          "foo"
        ]
      >>> pyarrow.StructArray.from_arrays(
          [
              [None, 1],
              [None, "foo"]
          ],
          fields=[pyarrow.field('col1', pyarrow.int64()), pyarrow.field("col2", pyarrow.string())]
      )
      -- is_valid: all not null
      -- child 0 type: int64
        [
          null,
          1
        ]
      -- child 1 type: string
        [
          null,
          "foo"
        ]
      

      The C++ API allows it, so it should be easy to add.

      see this so question

      Attachments

        Issue Links

          Activity

            People

              westonpace Weston Pace
              0x26dres &res
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 40m
                  1h 40m