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

Function NdarrayToArrow

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

Source from the content-addressed store, hash-verified

915}
916
917Status NdarrayToArrow(MemoryPool* pool, PyObject* ao, PyObject* mo, bool from_pandas,
918 const std::shared_ptr<DataType>& type,
919 const compute::CastOptions& cast_options,
920 std::shared_ptr<ChunkedArray>* out) {
921 if (!PyArray_Check(ao)) {
922 // This code path cannot be reached by Python unit tests currently so this
923 // is only a sanity check.
924 return Status::TypeError("Input object was not a NumPy array");
925 }
926 if (PyArray_NDIM(reinterpret_cast<PyArrayObject*>(ao)) != 1) {
927 return Status::Invalid("only handle 1-dimensional arrays");
928 }
929
930 NumPyConverter converter(pool, ao, mo, type, from_pandas, cast_options);
931 RETURN_NOT_OK(converter.Convert());
932 const auto& output_arrays = converter.result();
933 ARROW_DCHECK_GT(output_arrays.size(), 0);
934 *out = std::make_shared<ChunkedArray>(output_arrays);
935 return Status::OK();
936}
937
938Status NdarrayToArrow(MemoryPool* pool, PyObject* ao, PyObject* mo, bool from_pandas,
939 const std::shared_ptr<DataType>& type,

Callers

nothing calls this directly

Calls 7

TypeErrorFunction · 0.50
InvalidFunction · 0.50
OKFunction · 0.50
CastOptionsClass · 0.50
ConvertMethod · 0.45
resultMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected