You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Neal Richardson (Jira)" <ji...@apache.org> on 2020/01/17 23:46:00 UTC

[jira] [Resolved] (ARROW-7591) [Python] DictionaryArray.to_numpy returns dict of parts instead of numpy array

     [ https://issues.apache.org/jira/browse/ARROW-7591?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Neal Richardson resolved ARROW-7591.
------------------------------------
    Resolution: Fixed

Issue resolved by pull request 6212
[https://github.com/apache/arrow/pull/6212]

> [Python] DictionaryArray.to_numpy returns dict of parts instead of numpy array
> ------------------------------------------------------------------------------
>
>                 Key: ARROW-7591
>                 URL: https://issues.apache.org/jira/browse/ARROW-7591
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>            Reporter: Joris Van den Bossche
>            Assignee: Joris Van den Bossche
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.16.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Currently, the {{to_numpy}} method doesn't return an ndarray incase of dictionaryd type data:
> {code}
> In [54]: a = pa.array(pd.Categorical(["a", "b", "a"]))                                                                                                                                                             
> In [55]: a                                                                                                                                                                                                         
> Out[55]: 
> <pyarrow.lib.DictionaryArray object at 0x7f5c63d98f28>
> -- dictionary:
>   [
>     "a",
>     "b"
>   ]
> -- indices:
>   [
>     0,
>     1,
>     0
>   ]
> In [57]: a.to_numpy(zero_copy_only=False)                                                                                                                                                                          
> Out[57]: 
> {'indices': array([0, 1, 0], dtype=int8),
>  'dictionary': array(['a', 'b'], dtype=object),
>  'ordered': False}
> {code}
> This is actually just an internal representation that is passed from C++ to Python so on the Python side a {{pd.Categorical}} / {{CategoricalBlock}} can be constructed, but it's not something we should return as such to the user. Rather, I think we should return a decoded / dense numpy array (or at least error instead of returning this dict)
> (also, if the user wants those parts, they are already available from the dictionary array as {{a.indices}}, {{a.dictionary}} and {{a.type.ordered}})



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