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

[Python] Allow to subclass ExtensionArray to attach to custom extension type

    XMLWordPrintableJSON

Details

    Description

      Currently, you can define a custom extension type in Python with

      class UuidType(pa.ExtensionType):
      
          def __init__(self):
              pa.ExtensionType.__init__(self, pa.binary(16))
      
          def __reduce__(self):
              return UuidType, ()
      

      but the array you can create with this is always ExtensionArray. We should provide a way to define a subclass (eg `UuidArray` in this case) that can hold custom logic.

      For example, a user might want to define `UuidArray` such that `arr[i]` returns an instance of Python's `uuid.UUID`

      From https://github.com/apache/arrow/pull/4532#pullrequestreview-249396691

      Attachments

        Issue Links

          Activity

            People

              balancap Paul Balanca
              jorisvandenbossche Joris Van den Bossche
              Votes:
              0 Vote for this issue
              Watchers:
              4 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 - 5h
                  5h