Skip to content

Commit

Permalink
add test for chunked array
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Jan 5, 2025
1 parent 6019c99 commit a9fbe6e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/pyarrow/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,15 @@ def test_table_str_to_categorical_without_na(self, string_type):
table.to_pandas(strings_to_categorical=True,
zero_copy_only=True)

# chunked array
result = table["strings"].to_pandas(strings_to_categorical=True)
expected = pd.Series(pd.Categorical(values), name="strings")
tm.assert_series_equal(result, expected)

with pytest.raises(pa.ArrowInvalid):
table["strings"].to_pandas(strings_to_categorical=True,
zero_copy_only=True)

@pytest.mark.parametrize(
"string_type", [pa.string(), pa.large_string(), pa.string_view()]
)
Expand All @@ -1872,6 +1881,15 @@ def test_table_str_to_categorical_with_na(self, string_type):
table.to_pandas(strings_to_categorical=True,
zero_copy_only=True)

# chunked array
result = table["strings"].to_pandas(strings_to_categorical=True)
expected = pd.Series(pd.Categorical(values), name="strings")
tm.assert_series_equal(result, expected)

with pytest.raises(pa.ArrowInvalid):
table["strings"].to_pandas(strings_to_categorical=True,
zero_copy_only=True)

# Regression test for ARROW-2101
def test_array_of_bytes_to_strings(self):
converted = pa.array(np.array([b'x'], dtype=object), pa.string())
Expand Down

0 comments on commit a9fbe6e

Please sign in to comment.