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

[Python] Expose the offsets of a ListArray in python

    XMLWordPrintableJSON

    Details

      Description

      Assume the following ListArray:

      In [1]: arr = pa.ListArray.from_arrays(offsets=[0, 3, 5], values=[1, 2, 3, 4, 5])                                                                                                                                  
      
      In [2]: arr                                                                                                                                                                                                        
      Out[2]: 
      <pyarrow.lib.ListArray object at 0x7f11de71c708>
      [
        [
          1,
          2,
          3
        ],
        [
          4,
          5
        ]
      ]
      

      You can get the actual values as a flat array through .values / .flatten(), but there is currently no easy way to get back to the offsets (except from interpreting the buffers manually).

      We should probably add an offsets attribute (there is actually also a TODO comment for that).

        Attachments

          Activity

            People

            • Assignee:
              jorisvandenbossche Joris Van den Bossche
              Reporter:
              jorisvandenbossche Joris Van den Bossche
            • Votes:
              0 Vote for this issue
              Watchers:
              2 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 - 2h 40m
                2h 40m