[
https://issues.apache.org/jira/browse/ARROW-1689?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16214454#comment-16214454
]
ASF GitHub Bot commented on ARROW-1689:
---------------------------------------
njwhite commented on issue #1237: ARROW-1689: [Python] Implement
CategoricalBlock Index Zero-Copy
URL: https://github.com/apache/arrow/pull/1237#issuecomment-338509177
Thanks - I wrote a test for this behaviour when working on my PR!
````
diff --git a/python/pyarrow/tests/test_convert_pandas.py
b/python/pyarrow/tests/test_convert_pandas.py
index 8dd38582..21a5c82d 100644
--- a/python/pyarrow/tests/test_convert_pandas.py
+++ b/python/pyarrow/tests/test_convert_pandas.py
@@ -216,6 +216,19 @@ class TestPandasConversion(unittest.TestCase):
result = pa.array([0, 1, 2]).to_pandas(zero_copy_only=True)
npt.assert_array_equal(result, [0, 1, 2])
+ def test_zero_copy_dictionaries(self):
+ arr = pa.DictionaryArray.from_arrays(
+ np.array([0, 0]),
+ np.array(['A']))
+
+ result = arr.to_pandas(zero_copy_only=True)
+ values = pd.Categorical(['A', 'A'])
+
+ tm.assert_series_equal(
+ pd.Series(result),
+ pd.Series(values),
+ check_names=False)
+
def test_zero_copy_failure_on_object_types(self):
with self.assertRaises(pa.ArrowException):
pa.array(['A', 'B', 'C']).to_pandas(zero_copy_only=True)
````
----------------------------------------------------------------
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:
[email protected]
> [Python] Categorical Indices Should Be Zero-Copy
> ------------------------------------------------
>
> Key: ARROW-1689
> URL: https://issues.apache.org/jira/browse/ARROW-1689
> Project: Apache Arrow
> Issue Type: Improvement
> Components: Python
> Affects Versions: 0.7.1
> Reporter: Nick White
> Labels: pull-request-available
>
> It seems like
> [WriteIndices|https://github.com/apache/arrow/blob/0c8b861f93884f2868eb631d8fceee3a8b8905ec/cpp/src/arrow/python/arrow_to_pandas.cc#L955-L981]
> could reuse some of the logic in
> [ConvertValuesZeroCopy|https://github.com/apache/arrow/blob/0c8b861f93884f2868eb631d8fceee3a8b8905ec/cpp/src/arrow/python/arrow_to_pandas.cc#L1348-L1385]
> to avoid copying the integer indices array?
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)