jorisvandenbossche commented on code in PR #40482:
URL: https://github.com/apache/arrow/pull/40482#discussion_r1530479606
##########
python/pyarrow/tests/test_pandas.py:
##########
@@ -2522,6 +2522,89 @@ def test_list_values_behind_null(self):
else:
npt.assert_array_equal(left, right)
+ @pytest.mark.parametrize("klass", [pa.ListViewArray,
pa.LargeListViewArray])
+ def test_list_view_to_pandas_with_in_order_offsets(self, klass):
+ arr = klass.from_arrays(
+ offsets=pa.array([0, 2, 4]),
+ sizes=pa.array([2, 2, 2]),
+ values=pa.array([1, 2, 3, 4, 5, 6]),
+ )
+
+ actual = arr.to_pandas()
+ expected = pd.Series([[1, 2], [3, 4], [5, 6]])
+
+ tm.assert_series_equal(actual, expected)
+
+ @pytest.mark.parametrize("klass", [pa.ListViewArray,
pa.LargeListViewArray])
+ def test_list_view_to_pandas_with_out_of_order_offsets(self, klass):
+ arr = klass.from_arrays(
+ offsets=pa.array([2, 4, 0]),
+ sizes=pa.array([2, 2, 2]),
+ values=pa.array([1, 2, 3, 4, 5, 6]),
+ )
+
+ actual = arr.to_pandas()
+ expected = pd.Series([[3, 4], [5, 6], [1, 2]])
+
+ tm.assert_series_equal(actual, expected)
+
+ @pytest.mark.parametrize("klass", [pa.ListViewArray,
pa.LargeListViewArray])
+ def test_list_view_to_pandas_with_overlapping_offsets(self, klass):
+ arr = klass.from_arrays(
+ offsets=pa.array([0, 1, 2]),
+ sizes=pa.array([4, 4, 4]),
+ values=pa.array([1, 2, 3, 4, 5, 6]),
+ )
+
+ actual = arr.to_pandas()
+ expected = pd.Series([[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]])
+
+ tm.assert_series_equal(actual, expected)
+
+ @pytest.mark.parametrize("klass", [pa.ListViewArray,
pa.LargeListViewArray])
+ def test_list_view_to_pandas_with_null_values(self, klass):
+ arr = klass.from_arrays(
+ offsets=pa.array([0, 2, 2]),
+ sizes=pa.array([2, 0, 0]),
+ values=pa.array([1, None]),
+ mask=pa.array([False, False, True])
+ )
+
+ actual = arr.to_pandas()
+ expected = pd.Series([[1, None], [], None])
+
+ tm.assert_series_equal(actual, expected)
+
+ @pytest.mark.parametrize("klass", [pa.ListViewArray,
pa.LargeListViewArray])
+ def test_list_view_to_pandas_multiple_chunks(self, klass):
+ # ARROW-11855
+ gc.collect()
Review Comment:
This is probably from copy pasting from another test?
For clarity maybe clean that up here?
--
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]