Skip to content

Read into a DataFrame from Arrow IPC stream format

Description

Read into a DataFrame from Arrow IPC stream format

Usage

pl$read_ipc_stream(
  source,
  ...,
  columns = NULL,
  n_rows = NULL,
  row_index_name = NULL,
  row_index_offset = 0L,
  rechunk = TRUE
)

Arguments

source A character of the path to an Arrow IPC stream file.
These dots are for future extensions and must be empty.
columns A character vector of column names to read.
n_rows Stop reading from parquet file after reading n_rows.
row_index_name If not NULL, this will insert a row index column with the given name into the DataFrame.
row_index_offset Offset to start the row index column (only used if the name is set).
rechunk A logical value to indicate whether to make sure that all data is contiguous.

Value

A polars DataFrame

Examples

library("polars")


temp_file <- tempfile(fileext = ".arrows")

mtcars |>
  nanoarrow::write_nanoarrow(temp_file)

pl$read_ipc_stream(temp_file, columns = c("cyl", "am"))
#> shape: (32, 2)
#> ┌─────┬─────┐
#> │ cyl ┆ am  │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═════╪═════╡
#> │ 6.0 ┆ 1.0 │
#> │ 6.0 ┆ 1.0 │
#> │ 4.0 ┆ 1.0 │
#> │ 6.0 ┆ 0.0 │
#> │ 8.0 ┆ 0.0 │
#> │ …   ┆ …   │
#> │ 4.0 ┆ 1.0 │
#> │ 8.0 ┆ 1.0 │
#> │ 6.0 ┆ 1.0 │
#> │ 8.0 ┆ 1.0 │
#> │ 4.0 ┆ 1.0 │
#> └─────┴─────┘