View source: R/pkg-reticulate.R
| as_nanoarrow_schema.python.builtin.object | R Documentation |
These functions enable Python wrapper objects created via reticulate to
be used with any function that uses as_nanoarrow_array() or
as_nanoarrow_array_stream() to accept generic "arrowable" input.
Implementations for reticulate::py_to_r() and reticulate::r_to_py()
are also included such that nanoarrow's array/schema/array stream objects
can be passed as arguments to Python functions that would otherwise accept
an object implementing the Arrow PyCapsule protocol.
## S3 method for class 'python.builtin.object'
as_nanoarrow_schema(x, ...)
## S3 method for class 'python.builtin.object'
as_nanoarrow_array(x, ..., schema = NULL)
## S3 method for class 'python.builtin.object'
as_nanoarrow_array_stream(x, ..., schema = NULL)
test_reticulate_with_nanoarrow()
x |
An Python object to convert |
... |
Unused |
schema |
A requested schema, which may or may not be honoured depending on the capabilities of the producer |
This implementation uses the Arrow PyCapsule protocol to interpret an arbitrary Python object as an Arrow array/schema/array stream and produces Python objects that implement this protocol. This is currently implemented using the nanoarrow Python package which provides similar primitives for facilitating interchange in Python.
as_nanoarrow_schema() returns an object of class nanoarrow_schema
as_nanoarrow_array() returns an object of class nanoarrow_array
as_nanoarrow_array_stream() returns an object of class
nanoarrow_array_stream.
library(reticulate)
py_require("nanoarrow")
na <- import("nanoarrow", convert = FALSE)
python_arrayish_thing <- na$Array(1:3, na_int32())
as_nanoarrow_array(python_arrayish_thing)
r_to_py(as_nanoarrow_array(1:3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.