Skip to main content
Version: Python

to_table

to_table converts a PyArrow table to a Deephaven table.

Syntax

to_table(pa_table: pyarrow.Table, cols: list[str] = None) -> Table

Parameters

ParameterTypeDescription
pa_tablepyarrow.Table

A PyArrow table.

cols optionallist[str]

The columns to convert. Default is None, which means all columns.

Returns

A Deephaven Table.

Examples

The following example converts a PyArrow table to a Deephaven table:

from deephaven import arrow as dhpa
import pyarrow as pa

n_legs = pa.array([2, 4, 5, 100])
animals = pa.array(["Flamingo", "Horse", "Brittle stars", "Centipede"])
sizes = pa.array(["Medium", "Big", "Small", "Small"])
source_pa = pa.table({"n_legs": n_legs, "animals": animals, "sizes": sizes})

source = dhpa.to_table(pa_table=source_pa)

The following example converts a PyArrow table to a Deephaven table, but only the animals and n_legs columns:

from deephaven import arrow as dhpa
import pyarrow as pa

n_legs = pa.array([2, 4, 5, 100])
animals = pa.array(["Flamingo", "Horse", "Brittle stars", "Centipede"])
sizes = pa.array(["Medium", "Big", "Small", "Small"])
source_pa = pa.table({"n_legs": n_legs, "animals": animals, "sizes": sizes})

source = dhpa.to_table(pa_table=source_pa, cols=["animals", "n_legs"])