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

Function InferArrowType

python/pyarrow/src/arrow/python/inference.cc:793–810  ·  view source on GitHub ↗

Non-exhaustive type inference

Source from the content-addressed store, hash-verified

791
792// Non-exhaustive type inference
793Result<std::shared_ptr<DataType>> InferArrowType(PyObject* obj, PyObject* mask,
794 bool pandas_null_sentinels) {
795 if (pandas_null_sentinels) {
796 // ARROW-842: If pandas is not installed then null checks will be less
797 // comprehensive, but that is okay.
798 internal::InitPandasStaticData();
799 }
800
801 std::shared_ptr<DataType> out_type;
802 TypeInferrer inferrer(pandas_null_sentinels);
803 RETURN_NOT_OK(inferrer.VisitSequence(obj, mask));
804 RETURN_NOT_OK(inferrer.GetType(&out_type));
805 if (out_type == nullptr) {
806 return Status::TypeError("Unable to determine data type");
807 } else {
808 return std::move(out_type);
809 }
810}
811
812ARROW_PYTHON_EXPORT
813bool IsPyBool(PyObject* obj) { return internal::PyBoolScalar_Check(obj); }

Callers 1

ConvertPySequenceFunction · 0.70

Calls 4

InitPandasStaticDataFunction · 0.85
VisitSequenceMethod · 0.80
TypeErrorFunction · 0.50
GetTypeMethod · 0.45

Tested by

no test coverage detected