MCPcopy Create free account
hub / github.com/apache/arrow / convert_column

Function convert_column

python/pyarrow/pandas_compat.py:628–647  ·  view source on GitHub ↗
(col, field)

Source from the content-addressed store, hash-verified

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

Callers 1

dataframe_to_arraysFunction · 0.85

Calls 1

arrayMethod · 0.45

Tested by

no test coverage detected