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

ASF GitHub Bot commented on ARROW-2282:
---------------------------------------

xhochy commented on a change in pull request #1720: ARROW-2282: [Python] Create 
StringArray from buffers
URL: https://github.com/apache/arrow/pull/1720#discussion_r173858008
 
 

 ##########
 File path: python/pyarrow/tests/test_array.py
 ##########
 @@ -258,6 +258,26 @@ def test_union_from_sparse():
     assert result.to_pylist() == [b'a', 1, b'b', b'c', 2, 3, b'd']
 
 
+def test_string_from_buffers():
+    array = pa.array(["a", None, "b", "c"])
+
+    buffers = array.buffers()
+    copied = pa.StringArray.from_buffers(
+        len(array), buffers[1], buffers[2], buffers[0], array.null_count,
+        array.offset)
+    assert copied.to_pylist() == ["a", None, "b", "c"]
+
+    copied = pa.StringArray.from_buffers(
+        len(array), buffers[1], buffers[2], buffers[0])
+    assert copied.to_pylist() == ["a", None, "b", "c"]
+
+    sliced = array[1:]
+    copied = pa.StringArray.from_buffers(
+        len(sliced), buffers[1], buffers[2], buffers[0], -1, sliced.offset)
+    buffers = array.buffers()
+    assert copied.to_pylist() == [None, "b", "c"]
 
 Review comment:
   Done and worked out of the box :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] Create StringArray from buffers
> ----------------------------------------
>
>                 Key: ARROW-2282
>                 URL: https://issues.apache.org/jira/browse/ARROW-2282
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Python
>            Reporter: Uwe L. Korn
>            Assignee: Uwe L. Korn
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>
> While we will add a more general-purpose functionality in 
> https://issues.apache.org/jira/browse/ARROW-2281, the interface is more 
> complicate then the constructor that explicitly states all arguments:  
> {{StringArray(int64_t length, const std::shared_ptr<Buffer>& value_offsets, 
> …}}
> Thus I will also expose this explicit constructor.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to