You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Adam Hooper (Jira)" <ji...@apache.org> on 2019/11/26 14:38:00 UTC

[jira] [Comment Edited] (ARROW-7266) dictionary_encode() of a slice gives wrong result

    [ https://issues.apache.org/jira/browse/ARROW-7266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16982544#comment-16982544 ] 

Adam Hooper edited comment on ARROW-7266 at 11/26/19 2:37 PM:
--------------------------------------------------------------

Ah, found a workaround that should be good enough for now: {{pa.serialize(arr).deserialize().dictionary_encode()}}


was (Author: adamhooper):
Ah, found a workaround that should be good enough for now: `arr.serialize().deserialize().dictionary_encode()`

> dictionary_encode() of a slice gives wrong result
> -------------------------------------------------
>
>                 Key: ARROW-7266
>                 URL: https://issues.apache.org/jira/browse/ARROW-7266
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C++, Python
>    Affects Versions: 0.15.1
>         Environment: Docker on Linux 5.2.18-200.fc30.x86_64; Python 3.7.4
>            Reporter: Adam Hooper
>            Priority: Major
>
> Steps to reproduce:
> {code:python}
> import pyarrow as pa
> arr = pa.array(["a", "b", "b", "b"])[1:]
> arr.dictionary_encode()
> {code}
> Expected results:
> {code}
> -- dictionary:
>   [
>     "b"
>   ]
> -- indices:
>   [
>     0,
>     0,
>     0
>   ]
> {code}
> Actual results:
> {code}
> -- dictionary:
>   [
>     "b",
>     ""
>   ]
> -- indices:
>   [
>     0,
>     0,
>     1
>   ]
> {code}
> 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....



--
This message was sent by Atlassian Jira
(v8.3.4#803005)