Method: Polars::IO#read_ipc

Defined in:
lib/polars/io/ipc.rb

#read_ipc(source, columns: nil, n_rows: nil, memory_map: true, storage_options: nil, row_count_name: nil, row_count_offset: 0, rechunk: true) ⇒ DataFrame

Read into a DataFrame from Arrow IPC (Feather v2) file.

Parameters:

  • source (Object)

    Path to a file or a file-like object.

  • columns (Object) (defaults to: nil)

    Columns to select. Accepts a list of column indices (starting at zero) or a list of column names.

  • n_rows (Integer) (defaults to: nil)

    Stop reading from IPC file after reading n_rows.

  • memory_map (Boolean) (defaults to: true)

    Try to memory map the file. This can greatly improve performance on repeated queries as the OS may cache pages. Only uncompressed IPC files can be memory mapped.

  • storage_options (Hash) (defaults to: nil)

    Extra options that make sense for a particular storage connection.

  • row_count_name (String) (defaults to: nil)

    If not nil, this will insert a row count column with give name into the DataFrame.

  • row_count_offset (Integer) (defaults to: 0)

    Offset to start the row_count column (only use if the name is set).

  • rechunk (Boolean) (defaults to: true)

    Make sure that all data is contiguous.

Returns:

[View source]

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/polars/io/ipc.rb', line 27

def read_ipc(
  source,
  columns: nil,
  n_rows: nil,
  memory_map: true,
  storage_options: nil,
  row_count_name: nil,
  row_count_offset: 0,
  rechunk: true
)
  storage_options ||= {}
  _prepare_file_arg(source, **storage_options) do |data|
    _read_ipc_impl(
      data,
      columns: columns,
      n_rows: n_rows,
      row_count_name: row_count_name,
      row_count_offset: row_count_offset,
      rechunk: rechunk,
      memory_map: memory_map
    )
  end
end