(col, field)
| 627 | nthreads = 1 |
| 628 | |
| 629 | def convert_column(col, field): |
| 630 | if field is None: |
| 631 | field_nullable = True |
| 632 | type_ = None |
| 633 | else: |
| 634 | field_nullable = field.nullable |
| 635 | type_ = field.type |
| 636 | |
| 637 | try: |
| 638 | result = pa.array(col, type=type_, from_pandas=True, safe=safe) |
| 639 | except (pa.ArrowInvalid, |
| 640 | pa.ArrowNotImplementedError, |
| 641 | pa.ArrowTypeError) as e: |
| 642 | e.args += ( |
| 643 | f"Conversion failed for column {col.name} with type {col.dtype}",) |
| 644 | raise e |
| 645 | if not field_nullable and result.null_count > 0: |
| 646 | raise ValueError(f"Field {field} was non-nullable but pandas column " |
| 647 | f"had {result.null_count} null values") |
| 648 | return result |
| 649 | |
| 650 | def _can_definitely_zero_copy(arr): |
| 651 | return (isinstance(arr, np.ndarray) and |
no test coverage detected