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