Skip to content

Infer nanoarrow schema from a Polars object

Description

Infer nanoarrow schema from a Polars object

Usage

## S3 method for class 'RPolarsDataFrame'
infer_nanoarrow_schema(x, ..., compat_level = FALSE)

# S3 method for class 'RPolarsSeries'
infer_nanoarrow_schema(x, ..., compat_level = FALSE)

Arguments

x A polars object
Ignored
compat_level Use a specific compatibility level when exporting Polars’ internal data structures. This can be:
  • an integer indicating the compatibility version (currently only 0 for oldest and 1 for newest);
  • a logical value with TRUE for the newest version and FALSE for the oldest version.

Examples

library("polars")


library(nanoarrow)

pl_df = as_polars_df(mtcars)$select("mpg", "cyl")
pl_s = as_polars_series(letters)

infer_nanoarrow_schema(pl_df)
#> <nanoarrow_schema struct>
#>  $ format    : chr "+s"
#>  $ name      : chr ""
#>  $ metadata  : list()
#>  $ flags     : int 0
#>  $ children  :List of 2
#>   ..$ mpg:<nanoarrow_schema double>
#>   .. ..$ format    : chr "g"
#>   .. ..$ name      : chr "mpg"
#>   .. ..$ metadata  : list()
#>   .. ..$ flags     : int 2
#>   .. ..$ children  : list()
#>   .. ..$ dictionary: NULL
#>   ..$ cyl:<nanoarrow_schema double>
#>   .. ..$ format    : chr "g"
#>   .. ..$ name      : chr "cyl"
#>   .. ..$ metadata  : list()
#>   .. ..$ flags     : int 2
#>   .. ..$ children  : list()
#>   .. ..$ dictionary: NULL
#>  $ dictionary: NULL
infer_nanoarrow_schema(pl_s)
#> <nanoarrow_schema large_string>
#>  $ format    : chr "U"
#>  $ name      : chr ""
#>  $ metadata  : list()
#>  $ flags     : int 0
#>  $ children  : list()
#>  $ dictionary: NULL