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

Method Convert

python/pyarrow/src/arrow/python/numpy_to_arrow.cc:323–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321};
322
323Status NumPyConverter::Convert() {
324 if (PyArray_NDIM(arr_) != 1) {
325 return Status::Invalid("only handle 1-dimensional arrays");
326 }
327
328 if (dtype_->type_num == NPY_OBJECT) {
329 // If an object array, convert it like a normal Python sequence
330 PyConversionOptions py_options;
331 py_options.type = type_;
332 py_options.from_pandas = from_pandas_;
333 ARROW_ASSIGN_OR_RAISE(
334 auto chunked_array,
335 ConvertPySequence(reinterpret_cast<PyObject*>(arr_),
336 reinterpret_cast<PyObject*>(mask_), py_options, pool_));
337 out_arrays_ = chunked_array->chunks();
338 return Status::OK();
339 }
340
341 if (type_ == nullptr) {
342 return Status::Invalid("Must pass data type for non-object arrays");
343 }
344
345 // Visit the type to perform conversion
346 return VisitTypeInline(*type_, this);
347}
348
349namespace {
350

Callers 2

VisitMethod · 0.45
NdarrayToArrowFunction · 0.45

Calls 4

VisitTypeInlineFunction · 0.85
InvalidFunction · 0.50
OKFunction · 0.50
chunksMethod · 0.45

Tested by

no test coverage detected