AlenkaF commented on code in PR #35356:
URL: https://github.com/apache/arrow/pull/35356#discussion_r1251500889


##########
python/pyarrow/compute.py:
##########
@@ -333,6 +333,68 @@ def _make_global_functions():
 _make_global_functions()
 
 
+def dictionary_decode(arr, memory_pool=None):
+    """
+    Decodes the DictionaryArray to an Array.
+
+    Parameters
+    ----------
+    arr : Array-like
+    memory_pool : MemoryPool, optional
+        memory pool to use for allocations during function execution.
+
+    Examples
+    --------
+    >>> import pyarrow as pa
+    >>> import pyarrow.compute as pc
+    >>> x = pa.array(["a", "a", "b"], pa.dictionary(pa.int8(), pa.string()))
+    >>> x
+    <pyarrow.lib.DictionaryArray object at ...>
+    <BLANKLINE>
+    -- dictionary:
+      [
+        "a",
+        "b"
+      ]
+    -- indices:
+      [
+        0,
+        0,
+        1
+      ]
+
+    >>> x_decode = pc.dictionary_decode(x)
+    >>> x_decode
+    <pyarrow.lib.StringArray object at ...>
+    [
+      "a",
+      "a",
+      "b"
+    ]
+
+    The dictionary_decode actually call Cast in the deep implementation.
+    You can use Cast to decode DictionaryArray.
+
+    >>> x_decode_2 = pc.cast(x, pa.string())
+    >>> x_decode_2
+    <pyarrow.lib.StringArray object at ...>
+    [
+      "a",
+      "a",
+      "b"
+    ]
+
+    Returns
+    -------
+    array : decoded Array

Review Comment:
   ```suggestion
       decoded : Array
   ```



##########
python/pyarrow/compute.py:
##########
@@ -333,6 +333,68 @@ def _make_global_functions():
 _make_global_functions()
 
 
+def dictionary_decode(arr, memory_pool=None):
+    """
+    Decodes the DictionaryArray to an Array.
+
+    Parameters
+    ----------
+    arr : Array-like
+    memory_pool : MemoryPool, optional
+        memory pool to use for allocations during function execution.
+
+    Examples
+    --------
+    >>> import pyarrow as pa
+    >>> import pyarrow.compute as pc
+    >>> x = pa.array(["a", "a", "b"], pa.dictionary(pa.int8(), pa.string()))
+    >>> x
+    <pyarrow.lib.DictionaryArray object at ...>
+    <BLANKLINE>
+    -- dictionary:
+      [
+        "a",
+        "b"
+      ]
+    -- indices:
+      [
+        0,
+        0,
+        1
+      ]
+
+    >>> x_decode = pc.dictionary_decode(x)
+    >>> x_decode
+    <pyarrow.lib.StringArray object at ...>
+    [
+      "a",
+      "a",
+      "b"
+    ]
+
+    The dictionary_decode actually call Cast in the deep implementation.
+    You can use Cast to decode DictionaryArray.

Review Comment:
   ```suggestion
       ``dictionary_decode`` actually calls ``pyarrow.compute.cast`` in the
       deep implementation. You can also use `cast` function to decode a 
DictionaryArray.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to