apache / arrow-nanoarrow

Helpers for Arrow C Data & Arrow C Stream interfaces
https://arrow.apache.org/nanoarrow
Apache License 2.0
169 stars 35 forks source link

feat(python): function to inspect a single-chunk Array #436

Closed jorisvandenbossche closed 5 months ago

jorisvandenbossche commented 5 months ago

Addresses https://github.com/apache/arrow-nanoarrow/issues/435

Reusing the existing repr utilities, the current code gives this:

In [1]: import nanoarrow as na

In [2]: pa_arr = pa.array([[0, 1], [None, 3], None, [4]])

In [3]: arr = na.Array(pa_arr)

In [4]: arr.inspect()
<ArrowArray list<item: int64>>
- length: 4
- offset: 0
- null_count: 1
- buffers[2]:
  - validity <bool[1 b] 11010000>
  - data_offset <int32[20 b] 0 2 4 4 5>
- dictionary: NULL
- children[1]:
  'item': <ArrowArray int64>
    - length: 5
    - offset: 0
    - null_count: 1
    - buffers[2]:
      - validity <bool[1 b] 11011000>
      - data <int64[40 b] 0 1 0 3 4>
    - dictionary: NULL
    - children[0]: