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

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

wesm closed pull request #1586: ARROW-2124: [Python] Add test for empty item in 
array
URL: https://github.com/apache/arrow/pull/1586
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/pyarrow/tests/test_convert_pandas.py 
b/python/pyarrow/tests/test_convert_pandas.py
index 026cd2507..b73522d17 100644
--- a/python/pyarrow/tests/test_convert_pandas.py
+++ b/python/pyarrow/tests/test_convert_pandas.py
@@ -800,6 +800,14 @@ def test_column_of_lists(self):
             field = schema.field_by_name(column)
             _check_array_roundtrip(df[column], type=field.type)
 
+    def test_column_of_lists_first_empty(self):
+        # ARROW-2124
+        num_lists = [[], [2, 3, 4], [3, 6, 7, 8], [], [2]]
+        series = pd.Series([np.array(s, dtype=float) for s in num_lists])
+        arr = pa.array(series)
+        result = pd.Series(arr.to_pandas())
+        tm.assert_series_equal(result, series)
+
     def test_column_of_lists_chunked(self):
         # ARROW-1357
         df = pd.DataFrame({


 

----------------------------------------------------------------
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] ArrowInvalid raised if the first item of a nested list of numpy 
> arrays is empty
> ----------------------------------------------------------------------------------------
>
>                 Key: ARROW-2124
>                 URL: https://issues.apache.org/jira/browse/ARROW-2124
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>    Affects Versions: 0.8.0
>            Reporter: George Sakkis
>            Assignee: Uwe L. Korn
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>
> See example below:
> {noformat}
> In [1]: import numpy as np
> In [2]: import pandas as pd
> In [3]: import pyarrow as pa
> In [4]: num_lists = [[2,3,4], [3,6,7,8], [], [2]]
> In [5]: series = pd.Series([np.array(s, dtype=float) for s in num_lists])
> In [6]: pa.array(series)
> Out[6]: 
> <pyarrow.lib.ListArray object at 0x7f0db8ad1688>
> [
>   [2.0,
>    3.0,
>    4.0],
>   [3.0,
>    6.0,
>    7.0,
>    8.0],
>   [],
>   [2.0]
> ]
> In [7]: num_lists.append([])
> In [8]: series = pd.Series([np.array(s, dtype=float) for s in num_lists])
> In [9]: pa.array(series)
> Out[9]: 
> <pyarrow.lib.ListArray object at 0x7f0db8ad1e58>
> [
>   [2.0,
>    3.0,
>    4.0],
>   [3.0,
>    6.0,
>    7.0,
>    8.0],
>   [],
>   [2.0],
>   []
> ]
> In [10]: num_lists.insert(0, [])
> In [11]: series = pd.Series([np.array(s, dtype=float) for s in num_lists])
> In [12]: pa.array(series)
> ---------------------------------------------------------------------------
> ArrowInvalid                              Traceback (most recent call last)
> <ipython-input-99-fc3a903278e6> in <module>()
> ----> 1 pa.array(series)
> array.pxi in pyarrow.lib.array()
> array.pxi in pyarrow.lib._ndarray_to_array()
> error.pxi in pyarrow.lib.check_status()
> ArrowInvalid: trying to convert NumPy type object but got float64
> {noformat}



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

Reply via email to