Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion python/pyarrow/pandas_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@ def dataframe_to_arrays(df, schema, preserve_index, nthreads=1, columns=None):
nthreads = 1

def convert_column(col, ty):
return pa.array(col, from_pandas=True, type=ty)
try:
return pa.array(col, from_pandas=True, type=ty)
except (pa.ArrowInvalid, pa.ArrowTypeError) as e:
e.args += ("Conversion failed for column %s" % col.name,)
raise e

if nthreads == 1:
arrays = [convert_column(c, t)
Expand Down
5 changes: 5 additions & 0 deletions python/pyarrow/tests/test_convert_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,11 @@ def test_mixed_types_fails(self):
with pytest.raises(pa.ArrowTypeError):
pa.Table.from_pandas(data)

data = pd.DataFrame({'a': ['a', 1, 2.0]})
expected_msg = 'Conversion failed for column a'
with pytest.raises(pa.ArrowTypeError, match=expected_msg):
pa.Table.from_pandas(data)

def test_strided_data_import(self):
cases = []

Expand Down