Skip to content

Commit a9fbe6e

Browse files
add test for chunked array
1 parent 6019c99 commit a9fbe6e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

python/pyarrow/tests/test_pandas.py

+18
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,15 @@ def test_table_str_to_categorical_without_na(self, string_type):
18541854
table.to_pandas(strings_to_categorical=True,
18551855
zero_copy_only=True)
18561856

1857+
# chunked array
1858+
result = table["strings"].to_pandas(strings_to_categorical=True)
1859+
expected = pd.Series(pd.Categorical(values), name="strings")
1860+
tm.assert_series_equal(result, expected)
1861+
1862+
with pytest.raises(pa.ArrowInvalid):
1863+
table["strings"].to_pandas(strings_to_categorical=True,
1864+
zero_copy_only=True)
1865+
18571866
@pytest.mark.parametrize(
18581867
"string_type", [pa.string(), pa.large_string(), pa.string_view()]
18591868
)
@@ -1872,6 +1881,15 @@ def test_table_str_to_categorical_with_na(self, string_type):
18721881
table.to_pandas(strings_to_categorical=True,
18731882
zero_copy_only=True)
18741883

1884+
# chunked array
1885+
result = table["strings"].to_pandas(strings_to_categorical=True)
1886+
expected = pd.Series(pd.Categorical(values), name="strings")
1887+
tm.assert_series_equal(result, expected)
1888+
1889+
with pytest.raises(pa.ArrowInvalid):
1890+
table["strings"].to_pandas(strings_to_categorical=True,
1891+
zero_copy_only=True)
1892+
18751893
# Regression test for ARROW-2101
18761894
def test_array_of_bytes_to_strings(self):
18771895
converted = pa.array(np.array([b'x'], dtype=object), pa.string())

0 commit comments

Comments
 (0)