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

Function NdarrayToArrow

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

Source from the content-addressed store, hash-verified

981}
982
983Status NdarrayToArrow(MemoryPool* pool, PyObject* ao, PyObject* mo, bool from_pandas,
984 const std::shared_ptr<DataType>& type,
985 const compute::CastOptions& cast_options,
986 std::shared_ptr<ChunkedArray>* out) {
987 if (!PyArray_Check(ao)) {
988 // This code path cannot be reached by Python unit tests currently so this
989 // is only a sanity check.
990 return Status::TypeError("Input object was not a NumPy array");
991 }
992 if (PyArray_NDIM(reinterpret_cast<PyArrayObject*>(ao)) != 1) {
993 return Status::Invalid("only handle 1-dimensional arrays");
994 }
995
996 NumPyConverter converter(pool, ao, mo, type, from_pandas, cast_options);
997 RETURN_NOT_OK(converter.Convert());
998 const auto& output_arrays = converter.result();
999 ARROW_DCHECK_GT(output_arrays.size(), 0);
1000 *out = std::make_shared<ChunkedArray>(output_arrays);
1001 return Status::OK();
1002}
1003
1004Status NdarrayToArrow(MemoryPool* pool, PyObject* ao, PyObject* mo, bool from_pandas,
1005 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