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

[Python] dictionary_encode() of a slice gives wrong result

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.15.1
    • Fix Version/s: 0.16.0
    • Component/s: C++, Python
    • Environment:
      Docker on Linux 5.2.18-200.fc30.x86_64; Python 3.7.4

      Description

      Steps to reproduce:

      import pyarrow as pa
      arr = pa.array(["a", "b", "b", "b"])[1:]
      arr.dictionary_encode()
      

      Expected results:

      -- dictionary:
        [
          "b"
        ]
      -- indices:
        [
          0,
          0,
          0
        ]
      

      Actual results:

      -- dictionary:
        [
          "b",
          ""
        ]
      -- indices:
        [
          0,
          0,
          1
        ]
      

      I don't know a workaround. Converting to pylist and back is too slow. Is there a way to copy the slice to a new offset-0 StringArray that I could then dictionary-encode? Otherwise, I'm considering building buffers by hand....

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                apitrou Antoine Pitrou
                Reporter:
                adamhooper Adam Hooper
              • 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 - 10m
                  10m