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

[Python] Improve Table column access

    XMLWordPrintableJSON

Details

    Description

      Suppose you have a table column named "nulls". Right now, to access it on a table, you need to do something like this:

      >>> table.column(table.schema.get_field_index('nulls'))
      <pyarrow.lib.Column object at 0x7fe4144d2570>
      chunk 0: <pyarrow.lib.NullArray object at 0x7fe3db51b4a8>
      [
        NA,
        NA,
        NA
      ]
      

      Also, if you mistype the column name, instead of getting an error you get an arbitrary column:

      >>> table.column(table.schema.get_field_index('z'))
      <pyarrow.lib.Column object at 0x7fe3dbd6cc30>
      chunk 0: <pyarrow.lib.Int64Array object at 0x7fe3db54b408>
      [
        0,
        1,
        2
      ]
      

      Table.column() should accept a string object and return the column with the corresponding name. KeyError should be raised if there is no column with a such name.

      Attachments

        Issue Links

          Activity

            People

              keechongtan Kee Chong Tan
              apitrou Antoine Pitrou
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: