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
Parameter | Type | Description |
---|---|---|
pa_table | pyarrow.Table | A PyArrow table. |
cols optional | list[str] | The columns to convert. Default is |
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)
- source
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"])
- source